gpt4 book ai didi

ios - 如何唯一标识 UITableView 中的每个单元格

转载 作者:行者123 更新时间:2023-11-28 07:40:03 24 4
gpt4 key购买 nike

我有一个 UITableView,我正在尝试连接到另一个 viewcontroller,我需要行号,以便我可以从数组中选择一个字符串,这样我可以在下一个 View Controller 中显示这个字符串,我现在有这段代码。

let tableFrontView = segue.destination as! FCTableFrontViewController
tableFrontView.frontText = path[FlashCardsTableViewCell.init().tag].flashCardFront

FlashCardsTableViewCell.init().tag 目前正在返回一个 int 用于测试目的,尽管我想知道我可以用什么替换它以获得我选择的行号用户。谢谢

最佳答案

你可以这样尝试:

override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
let tableFrontView = segue.destination as! FCTableFrontViewController
let selectedIndexPath = tblView.indexPathForSelectedRow
let selectedRow = (selectedIndexPath?.row)!
print(selectedRow)
}

关于ios - 如何唯一标识 UITableView 中的每个单元格,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52529849/

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