0

我将我的 Xcode 更新到 7.3。在更新之前,我能够在出现任何错误或崩溃的情况下运行我的代码。更新后,当我在 iPhone 上运行以下代码时出现断言错误(有趣的是模拟器上没有错误)。

let storyboard =  UIStoryboard(name: storyboard, bundle: nil)
self.window?.rootViewController = storyboard.instantiateInitialViewController() as UIViewController!

错误

2016-03-24 16:15:25.891 Zilingo[434:92251] *** Assertion failure in -[UIStoryboard instantiateViewControllerWithIdentifier:], /BuildRoot/Library/Caches/com.apple.xbs/Sources/UIKit/UIKit-3512.60.7/UIStoryboard.m:171
error: Execution was interrupted, reason: breakpoint 5.1.
The process has been returned to the state before expression evaluation.

我错过了更新的某些步骤吗?

4

2 回答 2

1
Try to this format:-   

func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {

   // get your storyboard
   let storyboard = UIStoryboard(name: "Main", bundle: nil)

   // instantiate your desired ViewController
   let rootController = storyboard.instantiateViewControllerWithIdentifier("MyViewController") as! UIViewController

   // Because self.window is an optional you should check it's value first and assign your rootViewController
   if let window = self.window {
      window.rootViewController = rootController
   }

   return true
}
于 2016-03-24T11:17:20.207 回答
0

我遇到过同样的问题。就我而言,我忘记添加标识符字符串。让 vc = storyboard.instantiateViewControllerWithIdentifier("") 为!UIViewController

我像上面写的。我忘了添加标识符。在我添加标识符并且它起作用之后。

于 2021-07-02T11:42:41.543 回答