Is there a way to pop the current view from the Navigation Controller? Ideally in viewDidLoad
, I would like to perform some sanity checking and if it fails, popup an error dialog and automatically close the current view (remove from parent N.avigation Controller)
views:
126answers:
1
+2
A:
Look at the -popViewControllerAnimated:
method. You might also look at UIAlertView
for the error dialog box, and pop the current view controller from within the alert view delegate method, after the user clicks "OK" or the like.
Alex Reynolds
2010-04-29 19:37:28
If only there was some sort of documentation where you could find these things :)
willcodejavaforfood
2010-04-29 19:39:25
Knowing where to look is half the battle, sometimes.
Alex Reynolds
2010-04-29 19:40:24
I tried invoking [self.navigationController popViewControllerAnimated:YES]; in viewDidLoad but for some reason the current view doesn't get closed
theactiveactor
2010-04-29 20:13:13
You would not do error checking and popping in `-viewDidLoad`, but in `-viewDidAppear:`, instead. You want to wait for the view controller's view to appear before you pop back to the parent view controller.
Alex Reynolds
2010-04-29 20:20:53
Is there a particular reason that you're doing the sanity check after pushing the child view controller, instead of before? Seems like you'd not want to tax the phone and doing the sanity check beforehand might be faster and cleaner. On the other hand, this would depend on the sanity check and what you're actually testing, but I'm just throwing that out there.
Alex Reynolds
2010-04-29 20:37:51