Inside a button of a UITableViewCell, I have this function, that creates an automatic scroll to the next cell.
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)
}
I have an error on the line: "let indexPath = tableView.indexPathForRowAtPoint(point)!" saying: "Type of expression is ambiguous without more context"
Do you have any idea how to fix it? I would like to keep that code inside my UITableViewCell.
Many thanks
Cast the value returned by superview
var tableView = self.superview?.superview as! UITableView