I have an activation page in my app, which is mandatory for every user to activate the app. Once the app is activated, the user moves to the tabbed bar view.
I have created a tabbed bar application, where from my activationView on click of button I am trying to call the tab bar, I am getting an entire black screen.
- (IBAction)moveToActivateView:(id)sender {
AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
UITabBarController *tabBarController = [[UITabBarController alloc]init];
[self.view addSubview:tabBarController.view];
appDelegate.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
UIViewController *viewController1 = [[FirstViewController alloc] initWithNibName:@"FirstViewController" bundle:nil];
UIViewController *viewController2 = [[SecondViewController alloc] initWithNibName:@"SecondViewController" bundle:nil];
self.tabBarController.viewControllers = @[viewController1, viewController2];
appDelegate.window.rootViewController = self.tabBarController;
[appDelegate.window makeKeyAndVisible];}
Hey make your tabBarController's property in appDelegate and assign all ViewController there then call your tabBarController from yourViewController
in AppDelegate.h
in AppDelegate.m
Now in
InitialViewController
you can add yourTabBar and removeInitialViewController
And Follow my answer
Answer
You want to create dynamic tabbar application to resolve your problem. So you just create the view based application. in the view controller viewdidload method put these code
In user acceptation is yes button action call this code.
Did you realize that your local varialbe
tabBarController
is not identical but sort of hides the propertyself.tabBarController
? You create a newUITabBarCotnroller
and assign it to your local variabletabBarController
, which is accessible from this method only. Then you manipulate (add newly created view controllers) etc toself.tabBarController
.Self.tabBarController
could easily be nil here or anything else. But it is not the veryUITabBarController
that you just created.And it is
self.tabBarController
(so probably nil) what you assign to the window asrootViewController
.You do add the
tabBarController's
view as subview to self.view. Besides that I do not know what self acutally is, I don't think is it really nessessary to manually add the tabBar's view as subview. Setting the root view controller (properly) should be enough