Why is my segue causing an “unrecognized selector sent to instance” NSInvalidArgumentException?

限于喜欢 提交于 2019-12-23 20:56:03

问题


Trying to move from my first ViewController to my second ViewController (both using same storyboard), using a segue. My first ViewController has two buttons, one that says "Male", one that says "Female" (I know, not everyone associates with one of these two), and I want either, once clicked, to move to the second ViewController. I drag/dropped the button into my code to get the following:

@IBAction func femaleButton(_ sender: AnyObject)
{
    Globals.onboardingList.append("girl")
    print("it's a girl!")
    performSegue(withIdentifier: "femaleSegue", sender: self)
}

The Male button is identical. Using printlines I know that the program works until the "performSegue" line. I added visual segues and put their identifiers as maleSegue and femaleSegue. However, I am getting the following error:

Terminating app due to uncaught exception 'NSInvalidArgumentException', 
reason: '-[Train.SecondVC 
_setViewDelegateContentOverlayInsetsAreClean:]: unrecognized selector 
sent to instance 0x7fc482d02b00'

Thanks so much for any help!


回答1:


I can't figure the real problem as i believe you are not using the right identifier or made the segue connection from storyboard from the wrong view controller, however to make sure, please make one segue ctr + click on the button and drag it to the second screen and comment your action, if this works then remove that segue and the previous two segues and do it again but focus this time :)




回答2:


In my case I got this error because I had made a custom ViewController class and mistakenly assigned it to the View in the Storyboard instead of the ViewController. Check your Storyboard View and ViewControllers for custom classes and make sure you've set them appropriately.



来源:https://stackoverflow.com/questions/49502525/why-is-my-segue-causing-an-unrecognized-selector-sent-to-instance-nsinvalidarg

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