如果我使用storybard创建一个Tab Bar应用程序项目模板并将其放在我的AppDelegate.m中:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
NSLog(@"Root: %@", self.window.rootViewController);
NSLog(@"Current ViewController: %@", /*self.window.rootViewController.selectedIndexOrSomething?*/ );
return YES;
}
它说:Root:< UITabBarController:0x6b20360>
所以我猜TabBarController已经添加为window属性的subView,因为我没有以任何其他方式触及AppDelegate而不是NSLog。
如何记录当前标签/ ViewController?
答案 0 :(得分:0)
你会想要这样做:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
NSLog(@"Root: %@", self.window.rootViewController);
NSLog(@"Current ViewController: %@", ((UITabBarController *)self.window.rootViewController).selectedViewController );
return YES;
}