0

이미 UINavigationController가있는 응용 프로그램을 가지고 있지만 UITabBarController로 전환하고 싶습니다. 문제는 UItab이 처음부터 전환되어 작동하지 않기 때문에 위임 메서드에서 전환하는 것입니다. 그러나 그것도 작동하지 않습니다! 모든 코드는 앱의 대표자 인입니다.루트 뷰 컨트롤러 전환

self.navigationController = [[UINavigationController alloc] initWithRootViewController:[[UIViewController alloc] init]]; 
    self.tabBarController = [[UITabBarController alloc] init]; 


    if ([PFUser currentUser]) { 
     // Present wall straight-away 
     [self presentWallViewControllerAnimated:NO]; 
    } else { 
     // Go to the welcome screen and have them log in or create an account. 
     [self presentLoginViewController]; 
    } 

    [PFAnalytics trackAppOpenedWithLaunchOptions:launchOptions]; 

    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; 
    self.window.rootViewController = self.navigationController; 
    [self.window makeKeyAndVisible]; 

내가 그것을 전환 할 위임 방법 :

- (void)presentWallViewControllerAnimated:(BOOL)animated { 
    NSLog(@"Called:presentWallViewControllerAnimated "); 
// self.navigationController = nil; 

    self.tabBarController = [[UITabBarController alloc] init]; 

    PAWWallViewController *wallViewController = [[PAWWallViewController alloc] initWithNibName:nil bundle:nil]; 
    wallViewController.delegate = self; 


    // Set up the first View Controller 
    UIViewController *vc1 = [[UIViewController alloc] init]; 
    vc1.view.backgroundColor = [UIColor orangeColor]; 
    vc1.tabBarItem.title = @"Orange"; 
    vc1.tabBarItem.image = [UIImage imageNamed:@"heart"]; 

    // Set up the second View Controller 
    UIViewController *vc2 = [[UIViewController alloc] init]; 
    vc2.view.backgroundColor = [UIColor purpleColor]; 
    vc2.tabBarItem.title = @"Purple"; 
    vc2.tabBarItem.image = [UIImage imageNamed:@"star"]; 

    // Set up the Tab Bar Controller to have two tabs 

    [self.tabBarController setViewControllers:@[ vc1, vc2]]; 

    self.window.rootViewController = self.tabBarController; 

    [self.window makeKeyAndVisible]; 



// [self.window addSubview:tabBarController.view]; 
// [self.navigationController setViewControllers:@[ tabBarController ] animated:animated]; 
} 

답변

0

뷰 전환을 처리하기 위해 기억

UIViewController *vc = // any vc that's initialized properly  
window.rootViewController = vc; 

[UIView transitionWithView:window 
        duration:0.3 // 0.0 for immediate 
        options:UIViewAnimationOptionTransitionCrossDissolve // several enums to choose from here 
       animations:nil 
       completion:nil]; 

와 처음 후에 makeKeyAndVisible 필요하지 않습니다.

+0

이 중 하나가 작동하지 않았다. 여전히 검은보기가있는 navbar가 표시됩니다. – Abdoelrhman

0

당신은 - (void)presentWallViewControllerAnimated:(BOOL)animated라고하지만 didFinishLaunchingWithOptions의 끝에서 당신은

self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; 
self.window.rootViewController = self.navigationController; 
[self.window makeKeyAndVisible]; 

그래서 탭 표시 줄이 작동하지 않습니다

라고!

+0

그럼 어떻게해야합니까? – Abdoelrhman

+0

'didFinishLaunchingWithOptions'의 끝 부분에서이 코드를 제거하십시오. 그리고 if/else'if ([PFUser currentUser]) '코드에서 rootViewController를 확인하십시오. 위의 코드는 – Proton

+0

입니다. 로그인 또는 가입보기를 표시하려면 탐색 컨트롤러가 필요합니까? – Abdoelrhman

관련 문제