UITableView Selection Smoothing
If you use table views, and you need to smooth the transition a little bit when selecting a row and pushing a view controller, I’d recommend looking into ‘performSelector’. Its basically a timer which allows you to call a method after a certain short delay.
When using table views this gives the selected row enough time fully animate the selection, before moving onto the new view.
// our own method called from the performSelector
- (void)didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
MarketViewController *market = [[MarketViewController alloc]
initWithNibName:@"MarketViewController" bundle:nil];
market.eventMarket = [self.eventMarkets objectAtIndex:indexPath.row-1];
market.title = [[self.eventMarkets objectAtIndex:indexPath.row-1] marketName];
[self.navigationController pushViewController:market animated:YES];
[market release];
}
// delegate method for table
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
[self performSelector:@selector(didSelectRowAtIndexPath:) withObject:indexPath
afterDelay:0.1f];
}
Something else I just realised is that my tableviews weren’t automatically deselecting the rows when I returned from the push view controller. The following code rectifies that nicely (and smoothly).
-(void)viewDidAppear:(BOOL)animated {
[tableMarkets deselectRowAtIndexPath:[tableMarkets indexPathForSelectedRow]
animated:animated];
}