gpt4 book ai didi

ios - 在 AppDelegate 中切换 View (Swift)

转载 作者:行者123 更新时间:2023-11-28 08:47:26 25 4
gpt4 key购买 nike

我需要根据用户是否注册来设置我的应用程序的起始 View 。这将在 AppDelegate 中完成:

       func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
if(isUserRegistrated() == true){
let vc : AnyObject! = self.storyboard.instantiateViewControllerWithIdentifier("isRegistrated")
self.showViewController(vc as UIViewController, sender: vc)
}
else{
let vc : AnyObject! = self.storyboard.instantiateViewControllerWithIdentifier("isNOTRegistrated")
self.showViewController(vc as UIViewController, sender: vc)
}
}

此时我得到了错误:“AppDelegate 类型的值没有 Storyboard 的成员”

有什么结论吗?

最佳答案

示例:

let storyboard = UIStoryboard(name: "MyStoryboardName", bundle: nil)
let vc = storyboard.instantiateViewControllerWithIdentifier("someViewController") as! UIViewController
self.presentViewController(vc, animated: true, completion: nil)

关于ios - 在 AppDelegate 中切换 View (Swift),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34948824/

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