san*_*ner 6 uitableview ios swift
如何在Swift中单击其中一个单元格时创建静态表视图来创建操作?
我创建了一个静态表,就像应用程序的常规菜单一样,我可以在单击其中一个单元格时直接创建push segue.但与此同时,当我点击其中一个seques时,我想要运行以下功能.通过将单元格拖动到故事板中的UITableView,不会显示"创建操作"选项.
var goToProfiles = PFObject(className: "goToProfile")
goToProfiles["user"] = PFUser.currentUser()!.username
goToProfiles["goToUser"] = usernameLbl.text
goToProfiles.save()
Run Code Online (Sandbox Code Playgroud)
Rob*_*Rob 13
如果您使用部分,您还需要查询它们.
override func tableView(tableView: UITableView,
didSelectRowAtIndexPath indexPath: NSIndexPath) {
print(indexPath.section)
print(indexPath.row)
if indexPath.section == 1 && indexPath.row == 1 {
// do something
}
}
Run Code Online (Sandbox Code Playgroud)
我找到了以下代码的解决方案:
override func tableView(tableView: UITableView,
didSelectRowAtIndexPath indexPath: NSIndexPath) {
if indexPath.row == 1 {
//here you can enter the action you want to start when cell 1 is clicked
}
}
Run Code Online (Sandbox Code Playgroud)
小智 6
对于swift 3兼容性:
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
//Your action here
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
10313 次 |
| 最近记录: |