使用Xcode 7.3我为iPad布局添加了第二个故事板(到我的通用应用程序)。除定制segues外,一切正常。对于Main.storyboard,自定义segue工作正常,但如果我运行Main~iPad.storyboard(iPad设备或iPad模拟器),segue会崩溃。 崩溃报告如下:
2016-07-05 11:27:13.900 Quiz Maker[1354:42875] *** Assertion failure in -[UIStoryboardSegueTemplate segueWithDestinationViewController:], /BuildRoot/Library/Caches/com.apple.xbs/Sources/UIKit_Sim/UIKit-3512.60.7/UIStoryboardSegueTemplate.m:85
2016-07-05 11:27:13.926 Quiz Maker [1354:42875] ***由于未捕获的异常终止应用程序' NSInternalInconsistencyException',原因:'无法创建一个segue class'(null)''
继承我的自定义segue代码:
import UIKit
class CustomRightSegue: UIStoryboardSegue
{
override func perform()
{
let firstClassView = self.sourceViewController.view
let secondClassView = self.destinationViewController.view
let screenWidth = UIScreen.mainScreen().bounds.size.width
let screenHeight = UIScreen.mainScreen().bounds.size.height
secondClassView.frame = CGRectMake( screenWidth, 0, screenWidth, screenHeight)
if let window = UIApplication.sharedApplication().keyWindow {
window.insertSubview(secondClassView, aboveSubview: firstClassView)
UIView.animateWithDuration(0.4, animations: { () -> Void in
firstClassView.frame = CGRectOffset(firstClassView.frame, -screenWidth, 0)
secondClassView.frame = CGRectOffset(secondClassView.frame, -screenWidth, 0)
}) {(Finished) -> Void in
self.sourceViewController.navigationController?.pushViewController(self.destinationViewController, animated: false)
}
}
}
}
答案 0 :(得分:3)
将自定义Segue添加为Storyboard中两个ViewControllers之间的连接。
在那里,在Attributes Inspector中选择'Module'的可用选项: