Trouble Debugging UIButton

荒凉一梦 提交于 2019-12-12 03:07:04

问题


I am having some trouble with debugging a UIButton. There is an error I don't know how to fix. I almost certain it is within this code somewhere. Here is my code:

@IBAction func checkButton(sender: UIButton) {

    if (flashButton.hidden == true){
        flashButton.hidden == false
        flashingImageView.hidden == true
    }else if (flashButton.hidden == false)
    {
        flashButton.hidden == true
        flashingImageView.hidden == false
    }
    if ( "\(randomImageGeneratorNumber)" == "\(currentCountLabel.text)"){

        currentAmountCorrect + currentAmountCorrect + 1
        amountCorrectLabel.text = "\(currentAmountCorrect)"
    }else{
        currentAmountIncorrect = currentAmountIncorrect + 1
        amountIncorrectLabel.text = "\(currentAmountIncorrect)"
    }

    if (currentCountLabel.text == "0"){

      let alert = UIAlertView()
      alert.title = "Alert"
      alert.message = "You must type in an answer in order to check it"
      alert.addButtonWithTitle("Understood")
      alert.show()

    }

    currentCount *= 0
    currentCountLabel.text = "\(currentCount)"

}

The error in the debugger output says: '[ setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key CheckButton.'

I am not sure how to fix this. Any Suggestions?

Thanks in Advance.


回答1:


This can happen if you accidentally create an @IBOutlet to your button, and then just delete the IBOutlet from the code. In this situation, the Storyboard still tries to hook up the button to the @IBOutlet property in your ViewController, but it fails because the IBOutlet in the code is gone. If this is indeed what you did, to fix it:

  1. Control-click on the button in the Storyboard.
  2. From the list that pops up, scroll down to the Referencing Outlets section at the bottom.

  3. There, if you see an outlet listed, click on the x next to the ViewController to delete this outlet.



来源:https://stackoverflow.com/questions/28781565/trouble-debugging-uibutton

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!