首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >从表视图xib文件快速传递数据到视图控制器

从表视图xib文件快速传递数据到视图控制器
EN

Stack Overflow用户
提问于 2018-03-01 08:53:01
回答 1查看 1.1K关注 0票数 0

我试图将数据从作为xib文件的表传递给视图控制器,但由于某种原因,代码无法工作并引发错误。我也浏览过互联网,但没有找到解决方案。

viewDidLoad函数

代码语言:javascript
复制
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函数

代码语言:javascript
复制
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)
    }

误差截图

EN

Stack Overflow用户

发布于 2018-03-01 09:04:02

将此代码添加到didSelect方法中

代码语言:javascript
复制
let yourStoryboardObject = UIStoryboard(name: "yourStoryboardName", bundle: nil)

let vc = yourStoryboardObject?.instantiateViewController(withIdentifier: "PropertyDetailsVC") as? PropertyDetailsVC
票数 3
EN
查看全部 1 条回答
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/49045921

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档