I m using the library NMBottomTabBarController. (For ref. https://github.com/priankaliz/NMBottomTabBarController )
In AppDelegate.h I've declared property for tabBarController .
@property (nonatomic, strong) NMBottomTabBarController *customTabBarController;
In AppDelegate.m under didFinishLaunchingWithOptions
customTabBarController = (NMBottomTabBarController *)self.window.rootViewController;
customTabBarController.controllers = [NSArray arrayWithObjects:viewController1,viewController2,viewController3,viewController4 nil];
customTabBarController.delegate = self; HomeViewController *controller = [[HomeViewController alloc] initWithNibName:@"HomeViewController" bundle:nil];
[self.window setRootViewController:controller];
I've tableView
in HomeVC. When the row under table is clicked I want customTabBarController to be set as rootViewController
. For that I've written
- (void)tableView:(UITableView *)tableView1 didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
AppDelegate *appDelegate = [UIApplication sharedApplication].delegate;
[appDelegate.customTabBarController selectTabAtIndex:indexPath.row];
[appDelegate.window setRootViewController:appDelegate.customTabBarController.tabBarController];
}
This code is not working. I m not getting the tabBarCotroller screen. What is the correct way?
I think your problem is with this line
[appDelegate.window setRootViewController:appDelegate.customTabBarController.tabBarController];
Try by changing it like this:
[appDelegate.window setRootViewController:appDelegate.customTabBarController];
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.