作者热门文章
- Java 双重比较
- java - 比较器与 Apache BeanComparator
- Objective-C 完成 block 导致额外的方法调用?
- database - RESTful URI 是否应该公开数据库主键?
请快帮忙
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
}
错误是
Value of type 'UIViewController' has no member 'varView'
最佳答案
用您的目标 View Controller 更改 UIViewController。例如,您的目标 View Controller 名称是 YourViewController
并且还使用 if let 来安全解包
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
if let DestVC = segue.destinationViewController as? YouViewController {
var indexPath : NSIndexPath = self.tableView.indexPathForSelectedRow!
DestVC.varView = indexPath.row
}
关于ios - 类型 'UIViewController' 的值没有成员 'varView',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37004012/
请快帮忙 override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) { var DestVC =
我是一名优秀的程序员,十分优秀!