我在TabMenuController中使用MFSideMenu在SideMenu中,我已经添加了UITableview,所以当我单击单元格时,它导航到另一个视图控制器,但没有导航到该视图控制器
AppDelegate.m
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
centerViewController = [storyboard instantiateViewControllerWithIdentifier:@"Tabbarcontroller"];
TabViewController1 *tableView = [storyboard instantiateViewControllerWithIdentifier:@"TabViewController1"];
UINavigationController *nav1 = [[UINavigationController alloc] initWithRootViewController:tableView];
TabViewController2 *tableView2 = [storyboard instantiateViewControllerWithIdentifier:@"TabViewController2"];
UINavigationController *nav2 = [[UINavigationController alloc] initWithRootViewController:tableView2];
centerViewController.viewControllers = @[nav1,nav2];
UIViewController *leftSideMenuViewController = [storyboard instantiateViewControllerWithIdentifier:@"SideViewController"];
container = [MFSideMenuContainerViewController
containerWithCenterViewController:centerViewController
leftMenuViewController:leftSideMenuViewController
rightMenuViewController:nil];
self.window.rootViewController = container;
[self.window makeKeyAndVisible];
return YES;
}
SideMenu.m
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
ViewController3 *objEdit =[self.storyboard instantiateViewControllerWithIdentifier:@"ViewController3"];
AppDelegate *objApp = (AppDelegate *)[[UIApplication sharedApplication]delegate];
UINavigationController *navigationController = (UINavigationController *) objApp.centerViewController.navigationController;
NSLog(@"navigationcontroller :%@",objApp.centerViewController.navigationController);
[navigationController pushViewController:objEdit animated:YES];
[self.menuContainerViewController setMenuState:MFSideMenuStateClosed];
}
最佳答案
objApp.centerViewController是tabbarcontroller,因此您需要首先从tabor控制器中找出选定的视图控制器。如果要在所选选项卡中推送控制器,则应从tabbarcontroller的SelectedViewCOntroller获取Navigationcontroller。
UINavigationController *navigationController = (UINavigationController *) objApp.centerViewController.selectedViewController;
[navigationController pushViewController:objEdit animated:YES];
关于ios - MFSideMenu侧Viewcontroller无法导航到Tabbarcontroller中的特定 View Controller ,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/40189650/