0
votes

I have clean first page without UITabBarController , and UINavigationController is hidden , so when user went to second page , it will need UITabBarController with few tabs , so my question is how can i build a UITabBarController without make it rootViewController ..

in AppDelegate.m

MainViewController *mainviewController = [[MainViewController alloc] init];

UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:mainviewController];
[nav setNavigationBarHidden:YES];

self.window.rootViewController = nav;

in MainViewController.m after button get clicked

ShowViewController *showView = [ShowViewController new];
[self.navigationController pushViewController:showView animated:YES];

in ShowViewController.m

UIViewController *tm1 = [UIViewController new];
tm1.title = @"tm1";
tm1.view.backgroundColor = [UIColor redColor];

UIViewController *tm2 = [UIViewController new];
tm2.title = @"tm2";

UIViewController *tm3 = [UIViewController new];
tm3.title = @"tm3";

NSArray *tm = @[tm1,tm2,tm3];

UITabBarController *tabbarC = [UITabBarController new];
[tabbarC setViewControllers:tm animated:YES];

[[self navigationController] pushViewController:tabbarC animated:YES];

tabbarC didn't show .. xcode said : 2014-02-03 01:07:48.205 zhui002[45992:70b] Finishing up a navigation transition in an unexpected state. Navigation Bar subview tree might get corrupted. 2014-02-03 01:07:48.355 zhui002[45992:70b] Unbalanced calls to begin/end appearance transitions for .

so could anyone tell me is that possible to use UITabBarController to build what i want , or i should build it with UIButton and make it looks like tabbar ?

thx !

2

2 Answers

1
votes

The error Xcode is throwing most likely means you are trying to begin an animation before the previous animation has completed. You could try setting the animation property to NO in both the pushViewController calls to avoid getting the error.

A more elegant way to do what you are trying to do is make the ShowViewController a subclass of UITabBarController and set your tabs in viewDidLoad

0
votes

The answer is yes you can. Hook up your TabBarController as a segue for 2nd ViewController. It will still be a part of the navigation controller.