"Storyboard不包含带有标识符的视图控制器"仅在设备上 [英] 'Storyboard doesn't contain a view controller with identifier' only on Device
本文介绍了"Storyboard不包含带有标识符的视图控制器"仅在设备上的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有这个情节提要:
使用此ViewController:
With this ViewController :
我有这段代码可以实例化我的VC:
I have this code to instanciate my VC :
let VC = UIStoryboard(name: "Main_iPhone", bundle: nil).instantiateViewControllerWithIdentifier("POIListViewController")
当我在模拟器上运行时,一切正常.
When i'm running on simulator, everything works thine.
但是当我在真实设备上启动时,我有这个例外:
But when i launch on real device, i have this exception :
2016-07-12 10:56:19.073 App-Ely[1935:562264] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Storyboard (<UIStoryboard: 0x185481b0>) doesn't contain a view controller with identifier 'POIListViewController''
*** First throw call stack:
(0x2a23b5f7 0x37aadc77 0x2dc36f25 0x182b8c 0x182dd0 0x12d99f 0x2a1f3f15 0x2a14ee4d 0x2ae83ec1 0x13e0d5 0x168a2d 0x2d7f9607 0x2d8ab0a7 0x2d75d1f1 0x2d6d8eff 0x2a202015 0x2a1ff6f9 0x2a1ffafb 0x2a14cb31 0x2a14c943 0x3152c051 0x2d7426f1 0x16fce3 0x38049aaf)
libc++abi.dylib: terminating with uncaught exception of type NSException
我的故事板已正确加载:
I have my storyboard correctly loaded :
let storyboard = UIStoryboard(name: "Main_iPhone", bundle: nil)
// 'storyboardName' contains "Main_iPhone"
let storyboardName : String = storyboard.valueForKey("name") as! String
let VC = storyboard.instantiateViewControllerWithIdentifier("POIListViewController")
推荐答案
let storyboard = UIStoryboard(name: "Main_iPhone", bundle: nil)
let vc = storyboard.instantiateViewControllerWithIdentifier("POIListViewController") as! UIViewController
编辑
当您更改我认为的情节提要名称时,只需清洁您的项目(CMD + SHIFT + K).
Just CLEAN your project (CMD+SHIFT+K) as you have change the storyboard name I think.
这篇关于"Storyboard不包含带有标识符的视图控制器"仅在设备上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文