Here is a solution that seems to work. You can get the viewcontroller that you want to present modally from my TSFullScreenModalViewController, or you can just implement the code directly in the view controller itself.
@interface TSFullScreenModalViewController : UIViewController { UIWindow* _window; } - (void) presentFullScreenModal; @end @implementation TSFullScreenModalViewController - (void) viewDidDisappear:(BOOL)animated { [super viewDidDisappear: YES]; [_window resignKeyWindow]; [_window release]; _window = nil; } - (void) presentFullScreenModal { UIViewController* rvc = [[UIViewController new] autorelease]; rvc.view.backgroundColor = [UIColor clearColor]; _window = [[UIWindow alloc] initWithFrame: [UIScreen mainScreen].bounds] ; _window.windowLevel = UIWindowLevelStatusBar+1; _window.backgroundColor = [UIColor clearColor]; _window.rootViewController = rvc; [_window makeKeyAndVisible]; [UIApplication sharedApplication].statusBarHidden = YES; [rvc presentModalViewController: self animated: YES]; [UIApplication sharedApplication].statusBarHidden = NO; } @end
Print your modal view controller, for example:
@interface MyModalViewController : TSFullScreenModalViewController { } - (IBAction) onDismiss:(id)sender; @end
Use it from another view controller, for example:
- (IBAction) onShowModal:(id)sender { MyModalViewController* mmvc = [[MyModalViewController new] autorelease]; [mmvc presentFullScreenModal]; }
Finally, release the view controller, as usual:
- (IBAction) onDismiss:(id)sender { [self dismissModalViewControllerAnimated: YES]; }
source share