pushViewController不工作

时间:2016-11-22 06:53:30

标签: ios swift swrevealviewcontroller

我是 swift swrevealviewcontroller 的新手。我正面临一个问题!在我的幻灯片菜单(场景TableViewController两个蓝线绘制)选中的每一行然后应该打开particule scene(查看控制器)但不幸的是它没有打开。当我从表中选择行但pushViewController不工作时,没有错误和didselectRowAt触发。

  func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {

        let dvcStoryBordId = menuViewIds[(indexPath.row - 1 )]

        let viewController = storyboard?.instantiateViewController(withIdentifier: dvcStoryBordId )

        self.navigationController?.pushViewController(viewController!, animated: true)
    }

故事板

enter image description here

我错过了什么吗?这是正确的方法吗?自

更新:

self.navigationControllernil。还有其他选择吗?或没有导航

更新

故事板ID

menuViewIds = ["shareWithFriends","deliveryTracking", "controls", "support","myAccount"]

运行时视图

enter image description here

2 个答案:

答案 0 :(得分:1)

试试这个:

   func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {

         let dvcStoryBordId = menuViewIds[(indexPath.row - 1 )]
         let viewController = storyboard?.instantiateViewController(withIdentifier: dvcStoryBordId )
         var navigationController = UIApplication.sharedApplication().keyWindow?.rootViewController as! UINavigationController
         navigationController?.pushViewController(viewController!, animated: true)

   }

答案 1 :(得分:0)

试试这个:

func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {

         let dvcStoryBordId = menuViewIds[indexPath.row]
         let viewController = storyboard?.instantiateViewController(withIdentifier: dvcStoryBordId )
         let vc = windowRootViewController() as! SWRevealViewController
         let nvc = vc.frontViewController as! UINavigationController
         nvc.pushViewController(viewController, animated: true)
   } 

WindowRootVC():

func windowRootViewController() -> UIViewController {
    return (UIApplication.shared.delegate?.window??.rootViewController)!
}