6

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?

Chris Kooken
  • 32,730
  • 15
  • 85
  • 123
  • I'm assuming you'd want to close the form sheet. There may be something inherent about form sheets that make them 'always on top' because they show the views behind them as well. – valheru May 15 '14 at 01:48
  • @valheru I'd prefer not to close it... – Chris Kooken May 15 '14 at 14:17
  • What happens in 'PresentViewController'? Can you post that code? – Grant Amos May 15 '14 at 20:32
  • @GrantAmos-Enragedmrt PresentViewController is an Apple method. It's not mine. – Chris Kooken May 16 '14 at 01:06
  • `PresentViewController` is not an Apple's method. Actually it is not even a method but a function, and one that doesn't start with `UI`, so definitely custom code. – Rivera May 16 '14 at 02:13
  • @Rivera It's an apple method... ON UIViewController https://developer.apple.com/library/ios/documentation/uikit/reference/UIViewController_Class/Reference/Reference.html#//apple_ref/occ/instm/UIViewController/presentViewController:animated:completion: – Chris Kooken May 19 '14 at 03:06
  • `presentViewController:animated:completion:` is an Apple method, `PresentViewController()` is neither a method (looks like a function), nor is defined in `UIViewController`. – Rivera May 19 '14 at 07:25
  • I am using Xamarin. It's the same method as presentViewController:animated:completion: – Chris Kooken May 19 '14 at 15:09

4 Answers4

3

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];

}
augustzf
  • 2,385
  • 1
  • 16
  • 22
1

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.

Rivera
  • 10,792
  • 3
  • 58
  • 102
1

Make sure your top viewController's navigationController is the one presenting your demoViewController (your screen saver)

Refer to the link below for more help on the subject:

iPhone — How to find topmost view controller

Community
  • 1
  • 1
TechSeeko
  • 1,521
  • 10
  • 19
1

Try bringing the view to the front after being presented. On the completion block of presentViewController:animated:completion: try calling:

[self.view bringSubviewToFront: demoVideoController.view];
rymagno
  • 458
  • 2
  • 9