【问题标题】:Automatically moving to parent view controller自动移动到父视图控制器
【发布时间】:2015-10-15 20:29:14
【问题描述】:

我在我的应用程序中使用 mmdrawercontroller...当我从抽屉中选择一个 tableviewcell 时,我在导航控制器上推送 tableview A,然后在从 tableview A 中选择 tableviewcell 时,我在导航控制器上推送 tableview B... tableview B 出现,然后立即弹回 tableview A。

我在 tableview B 的 viewdidload 方法上进行了调试,导航控制器将 tableviewB 与 tableview A 和主视图一起推到了它上面...... tableview B 的所有 tableview 方法也被触发了......但后来不知何故 tableviewB 弹出并重新打开表视图 A... 这种奇怪行为的任何原因..?

注意

但是,当我以模态方式呈现自定义创建的 uinavigational 控制器时(通过以下代码 sn-p),它的行为正常......并且不会弹出......

 UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:tableviewB];

[self presentViewController:navigationController
                   animated:YES
                 completion:^{
                    NSLog(@"presenting modally rather pushing"); 
                 }];

所以导航控制器肯定出了问题..

【问题讨论】:

    标签: ios objective-c uitableview uinavigationcontroller mmdrawercontroller


    【解决方案1】:

    分享我用swift写的想法,如果你想从tableViewA推送tableViewB,在你的AppDelegate中:

    self.window = UIWindow()    
    let tvc = TableViewAController()
    let nvc = UINavigationController(rootViewController: tvc)    
    window.rootViewController = nvc
    window.makeKeyAndVisible()
    

    当你想在 tableViewA 中推送 tableViewB 时:

    let nextVC = TableViewBController()
    nvc.pushViewController(nextVC)
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-09-08
      • 2011-12-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多