gpt4 book ai didi

iOS 8 Storyboard/主界面

转载 作者:行者123 更新时间:2023-11-28 09:18:39 25 4
gpt4 key购买 nike

我正在创建一个 iOS 8 应用程序。我有两个适用于 iPhone 和 iPad 的 Storyboard。iPad.storyboard 设置为主界面。我的问题是每次我在 iPhone 设备上运行时,iPad.storyboard 仍然被调用。

有没有办法自动检测特定设备的 Storyboard?

最佳答案

//If you are looking for a swift solution
if(UIDevice.currentDevice().userInterfaceIdiom == UIUserInterfaceIdiom.Pad) {
//iPad
var iPadBoard: UIStoryboard!
iPadBoard = UIStoryboard(name: "iPad", bundle: nil)
let viewcontroller : UIViewController = iPadBoard.instantiateViewControllerWithIdentifier("iPad") as UIViewController
self.window!.rootViewController = viewcontroller
}
else {
//iPhone
var iPhoneBoard: UIStoryboard!
iPhoneBoard = UIStoryboard(name: "iPhone", bundle: nil)
let viewcontroller : UIViewController = iPhoneBoard.instantiateViewControllerWithIdentifier("iPhone5") as UIViewController
self.window!.rootViewController = viewcontroller
}

关于iOS 8 Storyboard/主界面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26268924/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com