![](/img/trans.png)
[英]How to share a UIManagedDocument using Storyboards with a Tab Bar Controller as initial controller?
[英]Using Multiple Storyboards with Tab Bar Controller
我试图让我的应用程序根据运行的设备加载不同的故事板。 现在,我已经能够检测到该设备并基于该设备在AppDelegate中设置rootViewController。 但是,我注意到当我这样做时,我的“标签栏控制器”消失了。 我认为这是因为我只是将rootViewController设置为新实例而已。 如何解决此问题,以便显示标签栏?
AppDelegate.swift
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
window = UIWindow(frame: UIScreen.mainScreen().bounds)
window?.makeKeyAndVisible()
if ((UIDevice.currentDevice().modelName == "iPhone 5") || (UIDevice.currentDevice().modelName == "iPhone 5c") || (UIDevice.currentDevice().modelName == "iPhone 5s") || (UIDevice.currentDevice().modelName == "iPhone SE") || (UIDevice.currentDevice().modelName == "iPod Touch 5") || (UIDevice.currentDevice().modelName == "iPod Touch 6")) {
storyboard = UIStoryboard(name: "iPhoneSE", bundle: nil)
let rootController = storyboard!.instantiateViewControllerWithIdentifier("login5")
if let window = self.window {
window.rootViewController = rootController
}
print("-----------------------iPhone5-----------------------")
} else if ((UIDevice.currentDevice().modelName == "iPhone 6") || (UIDevice.currentDevice().modelName == "iPhone 6s")){
storyboard = UIStoryboard(name: "iPhone6", bundle: nil)
let rootController = storyboard!.instantiateViewControllerWithIdentifier("login6")
if let window = self.window {
window.rootViewController = rootController
}
print("-----------------------iPhone6-----------------------")
}
只是一个愚蠢的主意:在实例化相关的StoryBoard之前,要使窗口可见。 尝试在条件语句之后移动makeKeyAndVisible()行。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.