今天遇到个问题,想在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 © 2013 - 2025 Tencent Cloud. All Rights Reserved. 腾讯云 版权所有
深圳市腾讯计算机系统有限公司 ICP备案/许可证号:粤B2-20090059 深公网安备号 44030502008569
腾讯云计算(北京)有限责任公司 京ICP证150476号 | 京ICP备11018762号 | 京公网安备号11010802020287
Copyright © 2013 - 2025 Tencent Cloud.
All Rights Reserved. 腾讯云 版权所有