gpt4 book ai didi

ios - 将多个 Storyboard与选项卡栏 Controller 一起使用

转载 作者:行者123 更新时间:2023-11-28 16:16:15 24 4
gpt4 key购买 nike

我试图让我的应用程序根据运行的设备加载不同的 Storyboard。现在,我已经能够检测到设备并基于它在 AppDelegate 中设置 rootViewController。但是,我注意到,当我这样做时,我的选项卡栏 Controller 消失了。我认为这是因为我只是将 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() 行。

关于ios - 将多个 Storyboard与选项卡栏 Controller 一起使用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39044203/

24 4 0
文章推荐: javascript - 将 validate ="required:true"添加到您的 html 中
文章推荐: html - 有没有一种简单的方法可以为 HTML
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com