在 UITableViewCell 的按钮内,我有这个函数,它创建一个自动滚动到下一个单元格。
var tableView = self.superview?.superview
let point = sender.convertPoint(CGPointZero, toView : tableView)
let indexPath = tableView.indexPathForRowAtPoint(point)!
if indexPath.row < tableView.numberOfRowsInSection(indexPath.section) {
let newIndexPath = NSIndexPath(forRow:indexPath.row + 1, inSection:indexPath.section)
tableView.scrollToRowAtIndexPath(
newIndexPath, atScrollPosition:.Top, animated: true)
}
我在一行中出错:“let indexPath = tableView.indexPathForRowAtPoint(point)!”说:“在没有更多上下文的情况下,表达类型是模棱两可的”
你知道怎么解决吗?我想将该代码保留在我的 UITableViewCell 中。
非常感谢
最佳答案
转换superview返回的值
var tableView = self.superview?.superview as! UITableView
关于ios - Swift 中 TableViewCell 中的 indexPathForRowAtPoint 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31630693/