2016-11-22 80 views
2

我是新来的ios与swiftswrevealviewcontroller。我面临一个问题!在我的幻灯片菜单(场景TableViewController两个蓝线绘制)每行选择时应该是开放particuler scene(视图控制器),但不幸它不是打开。有没有错误和didselectRowAt火,当我从表中选择行但pushViewController不工作。pushViewController不工作

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

做我错过了什么?这是正确的方式?自。

UPDATE:

self.navigationControllernil。有没有其他的选择?或者没有导航

更新:

故事板编号

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

运行时间视图

enter image description here

+2

请调试并检查self.navigationController是否为空。 – CrazyVK56

+0

@ user4887505 self.navigationController为零。我应该怎么做 –

+0

用“导航控制器”使你的“菜单控制器”。 – CrazyVK56

回答

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) 

    } 
+0

它正在工作,但后退按钮不显示..我该怎么办? –

+0

请立即检查。 – CrazyVK56

+0

更新代码很多的错误 –

相关问题