当我使用storyboard标识符点击tableview单元格时,我必须推送详细视图控制器。我已经设计了视图控制器。现在我必须通过点击左侧菜单中的表格视图单元格导航到设计的屏幕。我正在使用LGSideMenuController
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
UIStoryboard *mainStoryboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
if (indexPath.row == 0) {
ProfileViewController *profileVC = (ProfileViewController*)[mainStoryboard instantiateViewControllerWithIdentifier:PCProfileVC];
[self.leftMenuVC navigateToViewController:@"profileVC"];
}}
-(void)navigateToViewController:(UIViewController*)viewController{
[(UINavigationController *)[self sideMenuController].rootViewController pushViewController:viewController animated:YES];
[[self sideMenuController] hideLeftViewAnimated:YES completionHandler:nil];}
请帮我做。感谢
答案 0 :(得分:0)
为什么要在rootViewController中推送viewController。 如果此代码段是在ViewController.m中编写的,请尝试替换,
[(UINavigationController *)[self sideMenuController].rootViewController pushViewController:viewController animated:YES];
带
[[self sideMenuController].rootViewController.navigationController pushViewController:viewController animated:YES];
如果您的标识符PCProfileVC正确,则此代码应该有效。
请参阅此link以获取有关在UINavigationController中推送ViewController的信息。
答案 1 :(得分:-1)
试试这段代码:
YourViewControllerClass *viewController = [[UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil] instantiateViewControllerWithIdentifier:@"ViewController"];
// instanciate your viewcontroller
[(UINavigationController *)[self sideMenuController].rootViewController pushViewController:viewController animated:YES]; //push your viewcontroller
[[self sideMenuController] hideRightViewAnimated:YES completionHandler:nil]; //hide the menu