I am developing an app and have accidentally been running it on iOS Simulator 4.3; the app works fine.
Upon changing to iOS5 simulator, a button which is supposed to dismiss a modal view controller, no longer works? Any ideas why?
Below is my code:
(Method to call controller):
if (self.infoModalController == nil)
self.infoModalController = [[[InformationViewController alloc] initWithNibName:
NSStringFromClass([InformationViewController class]) bundle:nil] autorelease];
[self.navigationController presentModalViewController:self.infoModalController animated:YES];
(Method to dismiss):
- (void)dismissButtonPressed:(id)sender
{
[self.parentViewController dismissModalViewControllerAnimated:YES];
}
The view loads fine but it won’t dismiss?
Cheers in advance!
Lawrence
For iOS 5 you want to use presentingViewController in place of parentViewController.
Here are the relevant docs: http://developer.apple.com/library/ios/#documentation/UIKit/Reference/UIViewController_Class/Reference/Reference.html#//apple_ref/occ/instp/UIViewController/parentViewController
Update: I should mention that calling [self dismissModalViewController] from the modal will have the same result, the dismiss selector is just passed up the responder chain to the presenter.