gpt4 book ai didi

ios - 如何调用特定的 TableViewCell

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

这个 TableViewController 中的第一个单元格应该在用户的状态被点赞或收藏时提醒用户。我需要创建一个函数,这样当点击一个按钮时,它会调用这个表格 View 单元格并通知他们谁喜欢他们的照片。我只是不确定如何调用这个特定的表格 View 单元格。有人可以帮帮我吗?我已经搜索过 SO 和 Apples Swift 文档,但没有成功。

enter image description here

最佳答案

在您的 didSelectRowAtIndexPath tableview 委托(delegate)方法中,您可以获得他们点击的单元格的索引路径(行位置),然后如果您有一个数据数组(用于填充 tableview首先)你知道在哪里可以找到它是哪个通知/事件:

func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
let selectedItem = items.objectAtIndex(indexPath.row) as String
}

您还可以通过在方法中添加以下内容来获取单元格:

let cell = tableView.cellForRowAtIndexPath(indexPath)

关于ios - 如何调用特定的 TableViewCell,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34539577/

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