如果我使用的是 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)applicationUIApplication *)application didFinishLaunchingWithOptionsNSDictionary *)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/
欢迎光临 OStack程序员社区-中国程序员成长平台 (https://ostack.cn/) | Powered by Discuz! X3.4 |