2015-11-09 60 views
0

我有一個UINavigationController。它有它的主視圖控制器,其中包含一個滾動視圖,然後是2個表視圖和一個按鈕。如果我將按鈕設置爲pushViewController,這可以正常工作。如果我在didSelectRow上設置了任何一個tableView來pushViewController,沒有任何反應。我測試了讓tableViews在tap上打印self.navigationController,並打印nil,所以我知道由於某種原因它不能正確繼承導航控制器。UITableView裏面的滾動,UINavigationController裏面不能pushViewController

這是迅速。我可以得到這個工作正常,在ObjC完全相同的方式沒有問題。

回答

1

您可以重寫tableview中的功能

override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) { 
    let YourVC = YourViewController(); 
    YourVC.data = self.data[indexPath.section][indexPath.row]; 
    self.navigationController?.pushViewController(YourVC, animated: true); 
} 
相關問題