gpt4 book ai didi

xcode - 在启动时决定 Storyboard

转载 作者:行者123 更新时间:2023-11-30 13:26:48 24 4
gpt4 key购买 nike

我试图在应用程序委托(delegate)启动时在两个 Storyboard之间做出决定。首先,我删除了 Info.plist 中的 NSMainStoryboardFile = Main 条目,以防止自动加载 Storyboard。

然后我尝试从 AppDelegate 加载主 Storyboard,但这不起作用。

@NSApplicationMain
class AppDelegate: NSObject, NSApplicationDelegate {


func applicationDidFinishLaunching(aNotification: NSNotification) {
let storyboard = NSStoryboard(name: "Main", bundle: nil)
storyboard.instantiateInitialController()
}

我不知道为什么。希望有人能帮忙。

最佳答案

var window: UIWindow?

func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool
{
window=UIWindow(frame: UIScreen.mainScreen().bounds)

let storyboard = UIStoryboard(name: "Main", bundle: nil)
let navigationController:UINavigationController = storyboard.instantiateInitialViewController() as! UINavigationController
var rootViewController:UIViewController = storyboard.instantiateViewControllerWithIdentifier("LoginView") // LoginView is your view controller name

navigationController.viewControllers = [rootViewController]
self.window?.rootViewController = navigationController
self.window?.makeKeyAndVisible()
window?.backgroundColor=UIColor.blackColor()

return true
}

关于xcode - 在启动时决定 Storyboard,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37088009/

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