gpt4 book ai didi

ios - 从详细 View 快速访问父单元格

转载 作者:行者123 更新时间:2023-11-28 05:31:08 25 4
gpt4 key购买 nike

我有两个 View :带有我的海关单元格的 TableViewController 和带有详细信息的 ViewController。如果用户按下其中一个单元格 - 将转到详细 View 。

有什么方法可以在详细 View 中访问我的自定义单元格的属性吗?

最佳答案

在 Storyboard中,单击 segue 并从属性检查器中为 segue 命名。

然后创建一个prepareForSegue 覆盖函数。如果 segue.identifier 与您为 segue 指定的名称匹配,则您可以通过 sender 属性访问该单元格。假设您将 segue 命名为 mySegueName 并且您的自定义单元格类称为 MyCustomCell,那么代码将是:

override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {

if (segue.identifier == "mySegueName") {
let myCell = sender as MyCustomCell
// You can now access any property that is on your custom cell
// like myCell.customImageView
}

}

关于ios - 从详细 View 快速访问父单元格,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28306943/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com