表行动作与indexPath行隔离 [英] Table row action to segue with indexPath row
本文介绍了表行动作与indexPath行隔离的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
因此,我有一个表视图和一个自定义VC。
然后我有一个对象练习,其中 detailImage
作为属性。
如何从表行操作中将 indexPath.row
放入我的 prepareForSegue
函数中? p>
这将返回 nil
: self.tableView.indexPathForSelectedRow
重写功能prepareForSegue(segue:UIStoryboardSegue,sender:AnyObject?){
if segue.identifier == detailsSegue {
如果让indexPath = self.tableView.indexPathForSelectedRow {
让destinationController = segue.destinationViewController为! DetailViewController
print(self.exercises [indexPath.row] .image)
destinationController.detailImage = self.exercises [indexPath.row] .image
print( send)
}
}
}
解决方案
而不是在您的代码中:
如果让indexPath = self.tableView.indexPathForSelectedRow {
尝试一下:
如果让indexPath = self.tableView.indexPathForSelectedRow(){
So I have a table view and a Custom VC.
then I have an object exercises with detailImage
as property.
How can I get the indexPath.row
from the table row action into my prepareForSegue
function?
this returns nil
: self.tableView.indexPathForSelectedRow
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
if segue.identifier == "detailsSegue" {
if let indexPath = self.tableView.indexPathForSelectedRow {
let destinationController = segue.destinationViewController as! DetailViewController
print(self.exercises[indexPath.row].image)
destinationController.detailImage = self.exercises[indexPath.row].image
print ("send")
}
}
}
解决方案
Instead of this in your code:
if let indexPath = self.tableView.indexPathForSelectedRow {
Try this:
if let indexPath = self.tableView.indexPathForSelectedRow() {
这篇关于表行动作与indexPath行隔离的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文