我试图将数据从作为xib文件的表传递给视图控制器,但由于某种原因,代码无法工作并引发错误。我也浏览过互联网,但没有找到解决方案。
viewDidLoad函数
override func viewDidLoad() {
        super.viewDidLoad()
        dataPass()
       self.navigationItem.title = "Landlord List"
        propertyTabel.register(UINib(nibName: "PropertyCell", bundle: nil), forCellReuseIdentifier: "Cell")
        propertyTabel.dataSource = self
        propertyTabel.delegate = self
   }didSelectRowAt函数
override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
        let vc = storyboard?.instantiateViewController(withIdentifier: "PropertyDetailsVC") as? PropertyDetailsVC
        var dict = arrRes[indexPath.row]
        prop.userId = nullToNil(value: dict["user_id"]) as? String
        prop.id = nullToNil(value: dict["property_id"]) as? String
        prop.code = nullToNil(value: dict["property_code"]) as? String      
        present(vc!, animated: true, completion: nil)
    }误差截图

发布于 2018-03-01 09:04:02
将此代码添加到didSelect方法中
let yourStoryboardObject = UIStoryboard(name: "yourStoryboardName", bundle: nil)
let vc = yourStoryboardObject?.instantiateViewController(withIdentifier: "PropertyDetailsVC") as? PropertyDetailsVChttps://stackoverflow.com/questions/49045921
复制相似问题