이미 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];
}
이 중 하나가 작동하지 않았다. 여전히 검은보기가있는 navbar가 표시됩니다. – Abdoelrhman