在 IBAction 中:"arguments passed to call that takes no arguments"

In IBAction: "arguments passed to call that takes no arguments"

据我所知,解决此错误的最佳方法:

arguments passed to call that takes no arguments

将会使用

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)
    })

}

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

您应该使用 instantiateViewControllerWithIdentifier 而不是 instantiateInitialViewController

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

Instantiates and returns the view controller with the specified identifier.

You use this method to create view controller objects that you want to manipulate and present programmatically in your application. Before you can use this method to retrieve a view controller, you must explicitly tag it with an appropriate identifier string in Interface Builder.

This method creates a new instance of the specified view controller each time you call it.