Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

FullScreen Modal View controller showing UNDER a formsheet

In a root ViewController I am presenting a modal viewcontroller in full screen. This works fine most of the time. The issue I run into is when there is another Modal ViewController open as a form sheet. When this happens, my FullScreen VC is shown BEHIND the formsheet. What can I do about this?

Basically this "DemoViewController" is functioning as a screensaver for my app.

demoVideoController = new DemoVideoController(this) { View = { Frame = View.Bounds } };
demoVideoController.ModalPresentationStyle = UIModalPresentationStyle.FullScreen;
PresentViewController(demoVideoController, false, null);

Any ideas?

like image 293
Chris Kooken Avatar asked May 12 '14 23:05

Chris Kooken


People also ask

What is a UIViewController?

The UIViewController class defines the shared behavior that's common to all view controllers. You rarely create instances of the UIViewController class directly. Instead, you subclass UIViewController and add the methods and properties needed to manage the view controller's view hierarchy.


2 Answers

You can present your screensaver view in a new UIWindow that sits on top of all other windows in the app. For example, like this (assuming you have a UIWindow property named screenSaverWindow).

- (void)screenSaver
{
    UIView *view = [[UIView alloc] initWithFrame:self.view.bounds];
    view.backgroundColor = [UIColor blueColor];
    self.screenSaverWindow = [[UIWindow alloc] initWithFrame:self.view.bounds];
    self.screenSaverWindow.windowLevel = UIWindowLevelAlert + 1;
    [self.screenSaverWindow addSubview:view];
    [self.screenSaverWindow makeKeyAndVisible];

}
like image 152
augustzf Avatar answered Sep 23 '22 12:09

augustzf


My guess is that the model and the form controllers are being presented by different controllers.

Try to present everything from the same controller like window.rootController.

That way you can test if there is already a presentedViewController and dismiss it before presenting your modal one.

like image 33
Rivera Avatar answered Sep 23 '22 12:09

Rivera