[self.navigationController popViewControllerAnimates:YES]
is the best option, but if you are neither the same class as the controller of the controller, nor your delegate changes before calling the back button method, you can also try -
you must first define the return button ---
UIBarButtonItem *newBackButton = [[UIBarButtonItem alloc] initWithTitle: @"anyTitleForBackButton" style: UIBarButtonItemStyleBordered target: nil action: @selector(backButtonTapped)]; [[self navigationItem] setBackBarButtonItem: newBackButton]; [newBackButton release];
and then in the backButtonTapped method you can call -
[self.navigationController pushViewController:desiredViewController animated:YES]
Nishant Mahajan Dec 14 '11 at 1:06 p.m. 2011-12-14 13:06
source share