Simple segue not working in xcode 7

孤街浪徒 提交于 2019-12-12 02:49:02

问题


Simple segue that has worked for months performed with this command:

[self performSegueWithIdentifier:@"ExpirationWarningSegue" sender:self];

now yields this error:

*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Could not perform segue with identifier 'ExpirationWarningSegue'. A segue must either have a performHandler or it must override -perform.'

What? It's a segue. I command-drag from one UIViewController to another in the storyboard. I'm not writing code for this. The segue is defined in the storyboard with this exact identifier.

Why does this happen now that I have upgraded to xcode 7 when it used to work just fine?


回答1:


The error message tells you exactly what the problem is:

'Could not perform segue with identifier 'ExpirationWarningSegue'. A segue must either have a performHandler or it must override -perform.'

This is a custom segue. Therefore it must implement perform.

A cool feature of Xcode 7 / iOS 9 is that you can use a custom segue even where you have already specified a push (show) segue or a present (modal) segue. In that case, your perform must call super to get the original behavior.




回答2:


See my comment here. It is a simple custom segue implementation in objC. Porting it to swift is trivial.



来源:https://stackoverflow.com/questions/33483261/simple-segue-not-working-in-xcode-7

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