私はすでに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];
}
これはうまくいきませんでした。私はまだblackviewでnavbarを見ています – Abdoelrhman