Home > Back-end >  Unrecognized selector sent to instance for unhiding button
Unrecognized selector sent to instance for unhiding button

Time:09-29

import UIKit

class ViewController: UIViewController {
    @IBOutlet var continueLabel: UILabel!
    @IBOutlet var yesButton: UIButton!
    @IBOutlet var noButton: UIButton!
    
    override func viewDidLoad() {
        super.viewDidLoad()
        continueLabel.isHidden=true
        yesButton.isHidden=true
        noButton.isHidden=true        // Do any additional setup after loading the view.
    }
    
  
     
    @IBAction func continueButton(_sender: UIButton) {
        continueLabel.isHidden=false
        yesButton.isHidden=false
        noButton.isHidden=false
    }
    
    
}

I'm a bit new to IOS development and was practicing how to hide/unhide a button. On the view controller, I can get the button hidden but when I press the button to unhide - The following error is being thrown reason: '-[WelcomeApp.ViewController ContinueButton:]: unrecognized selector sent to instance 0x12b2061d0.

It was basically a button which displayed two options - Yes or No. The Yes button is linked to the next view controller modally.

CodePudding user response:

Function names, as variables, are case sensitive. You seem to have linked to ContinueButton() function, and then to have renamed it to continueButton(). Remove the link and recreate it, and then it should work.

CodePudding user response:

Check the connection inspector as shown in the pic:

connection inspector

You can see a yellow warning, you have to remove this connection first and then again make the connection.

  • Related