There are lots of questions regarding this problem, but the answers I have found so far are not applicable. In this case, the table works correctly in iOS 9.3.5, but not for iOS 10 (or 10.3.1)
I have ruled out:
- Not setting up the delegate properly. The delegate performs 3 functions,
didSelectRowAt
,heightForRowAt
, andeditActionsForRowAt
. The latter is the right-to-left swipe which gives the option to perform the exact same functionality as selecting the row.. These three functions work correctly on v9.3.5 (as tested via simulator and and older iPad I test with.) When I use v10 via the simulator or my iPhone SE, theheightForRowAt
, andeditActionsForRowAt
work but not thedidSelectRowAt
(and for that matter - I triedwillSelectRowAt
. It also did not work for v10.) - Any typographical error (because it works for 9.3.5)
I have not been able to find anything about a Swift change regarding tableView(:didSelectRowAt)
from iOS 9 to iOS 10.
Background
I have a view controller with a corresponding xib ("DetailVC"). This xib has a label then a tableview underneath the label. The table's cell is another xib.
The view controller presented via
let uomVC = DetailVC()
self.navigationController?.pushViewController(uomVC, animated: true)
Then within DetailVC, I use a NSFetchedDataController and connect it to tableview via the tableView Data Source delegate. (Core data loads and displays great.)
Code (I'll post additional code as needed/ requested - Swift 3)
viewDidLoad() - partial
let nib: String = "DetailCell"
let reuseID: String = "detailCell"
tableView.register(UINib.init(nibName: nib, bundle: nil), forCellReuseIdentifier: reuseID)
tableView(:cellForRowAt)
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: reuseID) as! IngredientDetailCell
cell.present(ingredient: _fetchedResultsController.object(at: indexPath))
cell.isUserInteractionEnabled = true // Added later as a guess per SO suggestions
return cell
}
For arguments sake - this won't print
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
print("Selected a row")
// delegate?.selectedIngredient(_fetchedResultsController.object(at: indexPath))
// self.navigationController?.popViewController(animated: true)
}
View