문제

I have an iPad app (XCode 4.6, ios 6.2, ARC and Storyboards). I need to get existing instance of the UITabBarController. This is my code, but it's obviously wrong. How do I correct it?

    UITabBarController *tabBarController = [self.storyboard instantiateViewControllerWithIdentifier:@"tabBarController"];
[tabBarController setSelectedIndex:0];
도움이 되었습니까?

해결책

You are instantiating a new UITabBarController instance as the method name suggests.

If you are in the context of a UIViewController within the UITabBarController, just use

self.tabBarController

If the context is not in UITabBarController, self.tabBarController return nil.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top