1

在此处输入图像描述

从我所见,解决此错误的最佳方法:

传递给不带参数的调用的参数

将使用

do {try ...} and catch {...}

但是,在这段代码中实现它似乎是不可能的!

@IBAction func onTapButton(sender: AnyObject) {

    btnFromNib.animate(1, completion: { () -> () in

        var myTabbarController = self.storyboard?.instantiateInitialViewController("myTabbarController") as! UITabBarController
        var appDelegate = UIApplication.sharedApplication().delegate as! AppDelegate
        appDelegate.window?.rootViewController = myTabbarController

        myTabbarController.transitioningDelegate = self

        self.presentViewController(myTabbarController, animated: true, completion: nil)
    })

}
4

1 回答 1

0

您正在尝试使用标识符参数实例化视图控制器,但您没有使用正确的方法。

您应该使用instantiateViewControllerWithIdentifier而不是instantiateInitialViewController.

参考:https ://developer.apple.com/library/ios/documentation/UIKit/Reference/UIStoryboard_Class/index.html#//apple_ref/occ/instm/UIStoryboard/instantiateViewControllerWithIdentifier :

实例化并返回具有指定标识符的视图控制器。

您可以使用此方法来创建要在应用程序中以编程方式操作和呈现的视图控制器对象。在您可以使用此方法检索视图控制器之前,您必须在 Interface Builder 中使用适当的标识符字符串显式标记它。

每次调用此方法时,都会创建指定视图控制器的新实例。

于 2016-03-23T16:14:57.793 回答