Present and dismiss modal view controller

First of all, when you put that code in applicationDidFinishLaunching, it might be the case that controllers instantiated from Interface Builder are not yet linked to your application (so “red” and “blue” are still nil). But to answer your initial question, what you’re doing wrong is that you’re calling dismissModalViewControllerAnimated: on the wrong controller! It … Read more

Iphone SDK dismissing Modal ViewControllers on ipad by clicking outside of it

I’m a year late, but this is pretty straightforward to do. Have your modal view controller attach a gesture recognizer to the view’s window: UITapGestureRecognizer *recognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleTapBehind:)]; [recognizer setNumberOfTapsRequired:1]; recognizer.cancelsTouchesInView = NO; //So the user can still interact with controls in the modal view [self.view.window addGestureRecognizer:recognizer]; [recognizer release]; The handling code: … Read more