I've created a UIViewController with a ContainerView that holds a UITableViewController. In the ParentViewController's ViewDidLoad() method I set up the parent child relationship between the two viewConrollers.
guard let childView = childViewController.view else {
return
}
addChildViewController(childViewController)
containerView.addSubview(childView)
... add constraints ...
childViewController.didMove(toParentViewController: self)
The UITableViewController is presented in the ContainerView. It is scrolling correctly, but the cell's do not highlight when tapped. Specifically, the animation where they change tint is not occurring. The delegate methods
-(BOOL)tableView:(UITableView *)tableView shouldHighlightRowAtIndexPath:(NSIndexPath *)indexPath {
return true;
}
-(void)tableView:(UITableView *)tableView didHighlightRowAtIndexPath:(NSIndexPath *)indexPath {
NSLog(@"Oh no you didn't!");
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
// stuff..
}
are all executing but the cell's tint never changes.
I've looked at the gestureRecognizers on the UITableView, and they seem to be in order, which you would expect considering the delegate methods are being triggered.
I've also run this both in the simulator and on my iPhone, and have observed the same behaviour on both.
Swift 3.0:
You have to set the cell selection style
cell.selectionStyle = .default