请帮忙

override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
    var DestVC = segue.destinationViewController as UIViewController

    var indexPath : NSIndexPath = self.tableView.indexPathForSelectedRow!

    DestVC.varView = indexPath.row // This is the error line

}

错误是

类型'UIViewController'的值没有成员'varView'

最佳答案

使用目标视图控制器更改UIViewController。
例如您的destinationviewcontroller名称为YourViewController并用于安全拆包

override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
if let DestVC = segue.destinationViewController as? YouViewController  {

var indexPath : NSIndexPath = self.tableView.indexPathForSelectedRow!

DestVC.varView = indexPath.row

}

10-07 16:44