0

当我使用情节提要标识符点击表格视图单元格时,我必须推送详细视图控制器。我已经设计了视图控制器。现在我必须通过点击左侧菜单中的表格视图单元格导航到设计的屏幕。我正在使用 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];}

请帮我做。谢谢

4

2 回答 2

0

为什么要在 rootViewController 中推送 viewController。如果这个代码片段是写在你的 ViewController.m 中的,那么尝试替换,

[(UINavigationController *)[self sideMenuController].rootViewController pushViewController:viewController animated:YES];

[[self sideMenuController].rootViewController.navigationController pushViewController:viewController animated:YES];

如果您的标识符 PCProfileVC 是正确的,那么此代码应该可以工作。

请参阅此链接以获取有关在 UINavigationController 中推送 ViewController 的信息。

于 2016-08-03T15:14:34.727 回答
-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 
于 2016-08-03T15:24:41.477 回答