How to deal with a presentModal inside a tabBar that needs to use
navigationController
I'm trying to push a view controller inside a presentmodal but nothing
happening. So, I have a loginController as rootViewController that push a
tabBarControler then inside one of tabBar views I open a presentModal. In
the presentModal I have an UITableView when clicked push another view but
when I try do this nothing happen. To try be more clear here's the
hierarchy:
LoginViewController(as root view controller) >>>push>>>
UITabBarController(HomeViewController and two others) >>>open>>>
PackViewController(presentModal) that needs to open another view by
pushViewController:
The code:
AppDelegate.m
self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen]
bounds]] autorelease];
LoginViewController_iPhone *loginViewController =
[[LoginViewController_iPhone alloc] init];
self.navigationController = [[[UINavigationController alloc]
initWithRootViewController:loginViewController] autorelease];
self.window.rootViewController = self.navigationController;
LoginViewController.m
- (void)viewDidLoad
{
[super viewDidLoad];
HomeViewController_iPhone *referenciaHomeViewController =
[[HomeViewController_iPhone alloc] init];
MapaViewController_iPhone *referenciaMapaViewController =
[[MapaViewController_iPhone alloc] init];
GuiaViewController_iPhone *referenciaMidiaViewController =
[[GuiaViewController_iPhone alloc] init];
UINavigationController *navHome = [[UINavigationController alloc]
initWithRootViewController:referenciaHomeViewController];
UINavigationController *navMapa = [[UINavigationController alloc]
initWithRootViewController:referenciaMapaViewController];
UINavigationController *navGuia = [[UINavigationController alloc]
initWithRootViewController:referenciaMidiaViewController];
self.tabBarController = [[UITabBarController alloc] init];
[self.tabBarController.tabBar setBackgroundImage:[UIImage
imageNamed:@"tabBarBackground"]];
[self.tabBarController.tabBar setSelectionIndicatorImage:[UIImage
imageNamed:@"tabBarSelected"]];
self.tabBarController.viewControllers = [NSArray arrayWithObjects:navHome,
navMapa, navGuia, nil];
}
- (void)login {
[self.navigationController pushViewController:self.tabBarController
animated:YES];
}
PackViewController.m (PRESENTMODAL):
- (void)tableView:(UITableView *)tableView
didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
[tableView deselectRowAtIndexPath:indexPath animated:YES];
CompraPackViewController_iPhone *controller =
[[CompraPackViewController_iPhone alloc] init];
[self.navigationController pushViewController:controller animated:YES];
[controller release];
}
No comments:
Post a Comment