ios - 自定义 segue 使用(第二个)iPad Storyboard崩溃

标签 ios iphone xcode ipad

使用 Xcode 7.3,我为 iPad 布局添加了第二个 Storyboard(到我的通用应用程序)。除了自定义 segue 之外,一切正常。对于 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' 而终止应用程序,原因:'无法创建类 '(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)

        }
    }

}

最佳答案

添加自定义 Segue 作为 Storyboard 中两个 ViewController 之间的连接。

在那里,在属性检查器中为“模块”选择一个可用选项:

Screenshot of the 'Module' Menu

关于ios - 自定义 segue 使用(第二个)iPad Storyboard崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38201403/

相关文章:

ios - collectionView cellForItemAt 没有被调用

ios - 迪尔德 : warning: What is this error?

ios - Xamarin.IOS 切换按钮?

iphone - 如何将为iPhone创建的项目更改为ipad(通用)?

ios - 如何为 Swift 实现 AVCam

swift - 如何在没有 Xcode 的情况下链接 CocoaPods 库(integrate_targets false)

ios - didDisconnectPeripheral 未调用 iOS Swift 3

iphone - 当我将覆盖添加到 mkmapview 时应用程序崩溃

iphone - Objective-c 中的时区偏移量?

iphone - 限制 iPhone 应用程序访问服务器