ios - 为什么我的 segue 导致 "unrecognized selector sent to instance"NSInvalidArgumentException?

标签 ios swift segue uistoryboard unrecognized-selector

尝试使用 segue 从我的第一个 ViewController 移动到我的第二个 ViewController(都使用相同的 Storyboard)。我的第一个 ViewController 有两个按钮,一个表示“男性”,一个表示“女性”(我知道,不是每个人都与这两个中的一个相关联),我希望其中一个按钮在单击后移动到第二个 ViewController。我将按钮拖/放到我的代码中以获得以下内容:

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

男性按钮是相同的。使用 printlines 我知道该程序一直运行到“performSegue”行。我添加了视觉转场并将它们的标识符设置为 maleSegue 和 femaleSegue。但是,我收到以下错误:

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

非常感谢您的帮助!

最佳答案

在我的例子中,我得到这个错误是因为我创建了一个自定义的 ViewController 类,并错误地将它分配给 Storyboard 中的 View 而不是 ViewController。检查您的 Storyboard View 和 ViewControllers 是否有自定义类,并确保您已正确设置它们。

关于ios - 为什么我的 segue 导致 "unrecognized selector sent to instance"NSInvalidArgumentException?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49502525/

相关文章:

ios - Swift 中两个 UIWebViews 之间的 URL?

swift - 使用prepareForSegue将特定数据传递到另一个Viewcontrol

ios - 如何像 Evernote 应用一样从 iPad 屏幕底部显示 UIView

ios - 如何比较两个 Struct 对象?

swift - 通过 SDWebImage 加载图像会占用项目的内存

ios - 使用 Storyboard 时更改 Popover 的大小

ios - AVPlayer,如果iPhone保持静音模式,如何播放有声视频?

IOS在另一个类中创建uitableview委托(delegate)

ios - NSRangeException 索引 9 超出范围 [0 .. 8]'

ios - 如何在 Controller 之间传递数据?