简体   繁体   English

Swift-将数据从表视图Xib文件传递到视图控制器

[英]Swift - Pass data from table view xib file to view controller

I am trying to pass data from my table which is a xib file to a view controller but for some reason, the code is not working and throwing an error. 我正在尝试将数据从xib文件的表传递给视图控制器,但是由于某种原因,代码无法正常工作并引发错误。 I have also browsed the internet, yet not got the solution. 我也浏览了Internet,但没有找到解决方案。

viewDidLoad Function 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 Function 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)
    }

Error Screenshot 错误截图

Add this code in your didSelect method 将此代码添加到您的didSelect方法中

let yourStoryboardObject = UIStoryboard(name: "yourStoryboardName", bundle: nil)

let vc = yourStoryboardObject?.instantiateViewController(withIdentifier: "PropertyDetailsVC") as? PropertyDetailsVC

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 将数据从表视图传递到视图控制器 - Pass data from table view to view controller 在iOS Swift 2中将数据从视图控制器传递到表视图控制器 - Passing data from view controller to table view controller in ios swift 2 在同一视图 controller 中将数据从集合视图传递到表视图: - pass data from collection view to table view in the same view controller: 如何将视图 controller 中的数据传递到表视图 controller? - How to pass the data from view controller to the table view controller? 从xib文件以模态形式显示View Controller - Present View Controller modally from xib file 将数据从视图控制器传递到MVC中的视图 - Swift - Pass Data From View Controller to View in MVC - Swift 如何将数据从视图 Controller 传递到 swift 中的容器视图 - How to pass data from View Controller to Container View in swift 将数据从Tabbar控制器传递到Swift和XCode中的视图控制器 - pass data from tabbar controller to view controller in swift and xcode 在Swift中将数据从View Controller传递到Child Controller - Pass data from View Controller to Child Controller in Swift 如何将不同的数据从表视图传递到另一个视图 controller - How to pass the different data from table view to another view controller
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM