FullScreen模态视图控制器显示在表单下方

时间:2014-05-12 23:45:34

标签: ios uiviewcontroller xamarin

在根ViewController中,我将全屏呈现模态视图控制器。这在大多数情况下都可以正常工作。我遇到的问题是当另一个Modal ViewController作为表单打开时。发生这种情况时,我的FullScreen VC显示在表单的后面。我该怎么办?

基本上这是" DemoViewController"是我的应用程序的屏幕保护程序。

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

有什么想法吗?

4 个答案:

答案 0 :(得分:3)

您可以在位于应用中所有其他窗口之上的新UIWindow中显示屏幕保护程序视图。例如,像这样(假设你有一个名为screenSaverWindow的UIWindow属性)。

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

}

答案 1 :(得分:1)

我的猜测是模型和表单控制器由不同的控制器呈现。

尝试展示来自同一个控制器的所有内容,例如window.rootController

这样你可以测试是否已经有presentedViewController并在呈现你的模态之前将其解除。

答案 2 :(得分:1)

确保您的顶级 viewController navigationController 是展示 demoViewController (您的屏幕保护程序)

有关此主题的更多帮助,请参阅以下链接:

iPhone — How to find topmost view controller

答案 3 :(得分:1)

尝试将视图显示在前面。在presentViewController:animated:completion:的完成块上尝试调用:

[self.view bringSubviewToFront: demoVideoController.view];