我正在尝试将数据从我的表(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)
}
错误屏幕截图
答案 0 :(得分:2)
在didSelect
方法
let yourStoryboardObject = UIStoryboard(name: "yourStoryboardName", bundle: nil)
let vc = yourStoryboardObject?.instantiateViewController(withIdentifier: "PropertyDetailsVC") as? PropertyDetailsVC