Search code examples
uitableviewios5pushviewcontrollernsindexpath

Checking for completed nav controller animation


I now know that If you push a view controller onto a navigation controller with animation, you must wait until that animation has completed before pushing another view controller otherwise you get warnings and possibly unexpected results.

How do you check to see if the nav controller animation has completed such to avoid this issue?

Thanks

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:    (NSIndexPath *)indexPath
{ 
    // ...


    //Make sure animation has completed before sending message below


[[self navigationController] pushViewController:detailsViewController animated:NO];

//...

}

Solution

  • If you rally want to push one VC at a time (nice movement to the right over many VCs) you can implement the UINavigationControllerDelegate in a controller class (app delegate will do), assign it/yourself to self.navigationController.delegate. UINavigationController will invoke navigationController:didShowViewController:animated: after each push.