gpt4 book ai didi

ios - segue时如何获取自定义单元格标签?

转载 作者:行者123 更新时间:2023-11-29 01:54:53 25 4
gpt4 key购买 nike

我正在尝试获取自定义单元格中所选行的名称。我如何在 Swift 中做到这一点?

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

var selectedCell = CustomCell()
selectedCell = tableView(tbl, cellForRowAtIndexPath: <#NSIndexPath#>)

if(segue.identifier == "next") {
var next = (segue.destinationViewController as! EngineViewController)
next.titleSub = selectedCell.cell.lblBrand.text
}
}

最佳答案

我相信如果您只是选择一个单元格,则该单元格应该是发件人。试试这个

if let selectedCell = sender as? CustomCell {
if(segue.identifier == "next") {
var next = (segue.destinationViewController as! EngineViewController)
next.titleSub = selectedCell.cell.lblBrand.text
}
}

关于ios - segue时如何获取自定义单元格标签?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30980900/

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