gpt4 book ai didi

iphone - 有没有办法让 App Delegate 运行条件,然后选择 Storyboard入口点?

转载 作者:塔克拉玛干 更新时间:2023-11-02 09:47:34 24 4
gpt4 key购买 nike

如果我使用 Storyboard并且入口点是 viewController1。

有没有办法让 App Delegate 运行条件,然后选择 Storyboard入口点 - viewController1 或 viewController2?

我想从 App Delegate 中选择是否打开位置服务,然后执行如下操作:

   (![CLLocationManager locationServicesEnabled]) 
{

self.viewController = [[viewController1 alloc] init];

NSLog(@"vc is viewController2 from app del. loc svcs off");

}
else if ([CLLocationManager locationServicesEnabled])
{
// alert location services denied

self.viewController = [[viewController2 alloc] init];

NSLog(@"vc is viewController2 from app del. loc svcs on");

NSLog(@"core location is on");

}

最佳答案

是的,你可以做到。

用下面的方法写下你的条件:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions

做这样的事情

if(Con1)
{
window.rootViewController = [window.rootViewController.storyboard instantiateViewControllerWithIdentifier:@"rootViewController1"];
}
else
{
window.rootViewController = [window.rootViewController.storyboard instantiateViewControllerWithIdentifier:@"rootViewController2"];
}

关于iphone - 有没有办法让 App Delegate 运行条件,然后选择 Storyboard入口点?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14750354/

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