Reputation: 733
I apologize for asking two similar questions but I don't think I worded it correctly the first time and am still struggling to find the answer.
I am in a viewcontroller
that is in a project containing a tabBarController
. I want to switch from the viewController
to one of the viewcontrollers contained in the tabbarcontroller
. The problem is it either doesn't show up at all or if I present the normal viewcontroller
there is no tab bar
.
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
UIViewController *viewController1 = [[[FirstViewController alloc] initWithNibName:@"FirstViewController" bundle:nil] autorelease];
self.tabBarController.viewControllers = @[viewController1, viewController2,viewController3);
}
I want to switch from my Tag view controller to FirstViewController
Tag.m
-(IBAction)save:(id)sender{
FirstViewController*vc =[[FirstViewController alloc] initWithNibName:@"FirstViewController" bundle:nil];
[self.tabBarController.viewControllers popToViewController:vc animated:YES];
}
Update:
I solved this by adding my ViewController
to a TabBar
within my .m file then
[_tabBarController setSelectedIndex:0];
[self presentViewController: _tabBarController animated:YES completion:NULL];
Thanks for the responses I got on this question.
Upvotes: 0
Views: 106
Reputation: 6342
You can change rootViewController
property of mainWindow
of AppDelegate
some thing like this.
AppDelegate * appDel = (AppDelegate*)[[UIApplication sharedApplication] delegate];
[appDel.window setRootViewController:tabBarController];
Enjoy..
Upvotes: 1