我有一个UITableView并且我正试图对另一个viewcontroller进行分段,我需要行号,这样我就可以从数组中选择一个字符串,这样我就可以在下一个视图控制器中显示这个字符串,我现在有这个代码。

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/

10-09 21:24