TableViewCell 中的条形按钮项目未在 didSelectRowAtIndexPath 中注册
Bar Button Item in TableViewCell is not registering in didSelectRowAtIndexPath
func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
selectedRow = indexPath.row
articleUser = userids2[indexPath.row]
self.performSegueWithIdentifier("jump", sender: self)
}
@IBAction func Share(sender: AnyObject) {
shareArticleUrl = articleUrls[selectedRow]
shareText = "Check Out This \(shareArticleUrl)"
let activityVC:UIActivityViewController = UIActivityViewController(activityItems: [shareText], applicationActivities: nil)
self.presentViewController(activityVC, animated: true, completion: nil)
}
我目前在表格视图的每个单元格中都有一个工具栏。更新到 Swift 2 后,当条形按钮项被 select 编辑时,它不是先 运行 didSelectRowAtIndexPath
函数而是直接跳转到 share
功能。我需要使用 didSelect
函数中的 indexpath.row
来 select articleUrl
列表中的正确项目。在更新到 Swift 2.
之前,上述技术工作正常
我曾尝试将 let selectedIndex = self.tableView.indexPathForCell(sender as! UITableViewCell)
合并到 share
函数中,但我没能成功。
为什么不将标签栏上的标签设置为行号,同时将其添加到 cellForRowAtIndexPath:
中,然后在 Share
函数中从传入的 [=12] 中检索它=].
func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
selectedRow = indexPath.row
articleUser = userids2[indexPath.row]
self.performSegueWithIdentifier("jump", sender: self)
}
@IBAction func Share(sender: AnyObject) {
shareArticleUrl = articleUrls[selectedRow]
shareText = "Check Out This \(shareArticleUrl)"
let activityVC:UIActivityViewController = UIActivityViewController(activityItems: [shareText], applicationActivities: nil)
self.presentViewController(activityVC, animated: true, completion: nil)
}
我目前在表格视图的每个单元格中都有一个工具栏。更新到 Swift 2 后,当条形按钮项被 select 编辑时,它不是先 运行 didSelectRowAtIndexPath
函数而是直接跳转到 share
功能。我需要使用 didSelect
函数中的 indexpath.row
来 select articleUrl
列表中的正确项目。在更新到 Swift 2.
我曾尝试将 let selectedIndex = self.tableView.indexPathForCell(sender as! UITableViewCell)
合并到 share
函数中,但我没能成功。
为什么不将标签栏上的标签设置为行号,同时将其添加到 cellForRowAtIndexPath:
中,然后在 Share
函数中从传入的 [=12] 中检索它=].