2017-08-05 8 views
0

iOSアプリの作成中に問題が発生しました。それは非常に簡単ですが、私は奇妙です。editActionsForRowを使用してView Controllerをプッシュできません。

私は1つのアクションを返すTableViewとeditActionsForRowAtを持っています。それをクリックすると、.xibファイルからロードされた2番目のViewControllerに移動する必要があります。私は、このボタンがクリックされたときにこの機能が実行されるが、VCは開かないことを知っている。

MainViewController.swift

func tableView(_ tableView: UITableView, editActionsForRowAt indexPath: IndexPath) -> [UITableViewRowAction]? { 
     let action = UITableViewRowAction(style: .normal, title: "more") { (uiTableViewRowAction, indexPath) in 

      let detailsVC = DetailsViewController(nibName: "DetailsViewController", bundle: nil) 
      self.navigationController?.pushViewController(detailsVC, animated: true) 

     } 

     return [action] 
    } 

DetailsViewController.swift(それは今のところ空の)

import UIKit 

    class DetailsViewController: UIViewController { 

     override func viewDidLoad() { 
      super.viewDidLoad() 

      // Do any additional setup after loading the view. 
     } 

    } 

それはなぜそれは私が思ってしまうので、私は過去に何回このpushViewController方法の複数を呼び出しました表示されません。どうしたの?

編集:

presentはどちらか動作しません。

present(detailsVC, animated: true, completion: nil) 戻り

TableView[2646:125041] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '-[UIViewController _loadViewFromNibNamed:bundle:] loaded the "DetailsViewController" nib but the view outlet was not set.'

答えて

0

が問題だったかわからないが、私はDetailsVCの.swiftと.xibを削除し、新しいものを作成し、コードの上に正常に動作します...

関連する問題