赞
踩
今天遇到个问题,想在didFinishLaunchingWithOptions方法里获取storyBoard的rootViewController。然后监听TabbarViewControllerde 点击事件(我的项目是storyBoard --> TabbarViewController形式)
问题一: didFinishLaunchingWithOptions 和 storyBoard 创建的方法,是怎么一个顺序呢。
由此发现didFinishLaunchingWithOptions之前已经Storyboard已经准备好了,UIApplication的rootViewController也准备好了。
跟踪一下找到了rootViewController ,获取如下:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.
UITabBarController * tabBar = (UITabBarController *)application.delegate.window.rootViewController;
tabBar.delegate = self;
return YES;
}
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。