I'm building a detail view for a UITableView. The detail view contains a UITableView which has two rows, and I want the first one to be selected when the detail view is opened. I have tried to use the method [selectRowAtIndexPath:animated:scrollPosition]
in [viewWillAppear]
:
- (void) viewWillAppear:(BOOL)animated {
[[self tableView] selectRowAtIndexPath:[NSIndexPath indexPathForRow:kStartDateRow inSection:kSection]
animated:NO
scrollPosition:UITableViewScrollPositionNone];
}
However, the selection is not affected by this, and using it in [viewDidAppear]
means the selection changes once the view has moved into place. How can I make the selection before the detail view appears on screen?
You can see an example of the behaviour I want in the Settings app. Go to General > Date & Time > Set Date & Time.