2013-01-17 1 views
0

스토리 보드를 사용하여 새로운 탭 응용 프로그램을 생성했습니다.현재 UITabBarController의 모달보기

지금까지 내가 가진

TabBarController -> FirstViewController -> SecondViewController -> ModalViewController 나는 tabBarController를 표시하기 전에 모달 뷰를 엽니 다하기 위해 노력하고있어

. 나는 application:didFinishLaunchingWithOptions:;

- (void)showModalView 
{ 
    UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil]; 
    GSLoginViewController *loginView = [storyboard instantiateViewControllerWithIdentifier:@"loginView"]; 
    [loginView setModalPresentationStyle:UIModalPresentationFullScreen]; 
    [self.window.rootViewController presentViewController:loginView animated:YES completion:NULL]; 
} 

에서

showModalView가 호출되는 AppDelegate.m에 다음 코드를 추가 그리고 여기에 출력 내가 가진 : AppDelegate에이 없기 때문에

Warning: Attempt to present <ModalViewController: 0x93670d0> on 
<UITabBarController: 0x935d170> whose view is not in the window hierarchy! 
+0

[여기] [1]에서 답을 찾을 수 있습니다. [1] : http://stackoverflow.com/questions/11862883/whose-view-is-not-in-the-window-hierarchy –

답변

5

이지고있다 tabbarcontroller가 루트 뷰라는 것을 알고 있습니다. 이런 식으로 시도해야합니다.

UITabBarController *tabBarController = (UITabBarController *)self.window.rootViewController; 

코드를 적절히 추가하십시오. 앱 위임자는 tabbarcontroller가 rootviewcontroller임을 알게해야합니다.

관련 문제