dismissViewControllerAnimated is called but ViewController is not dismissed

Ad Taylor picture Ad Taylor · Jan 24, 2012 · Viewed 69.5k times · Source

I am having a problems with the dismissViewControllerAnimated method not closing down the view.

What is happening in the app here is:

  • Cell in ItemViewController is selected.
  • View is pushed to ItemDetailViewControllerand details are sent through a delegate
  • User selects 'done' and the event is sent via a delegate to be closed in ItemViewController

All of this works except for the View is not dismissed, there are no errors. Can anyone see what is wrong?

- (void)itemDetailViewControllerDidFinish:(ItemDetailViewController *)controller
{
    NSLog(@"Controller: %@", controller);
    // Returns - Controller: <ItemDetailViewController: 0x6b68b60>

    [self dismissViewControllerAnimated:YES completion:nil];
}

Answer

Nick Lockwood picture Nick Lockwood · Jan 24, 2012

What if you call [controller.navigationController popViewControllerAnimated:YES] instead?

For that matter, what if you call [controller dismissViewControllerAnimated:YES completion:nil] instead of calling it on self?