简体   繁体   English

在模态视图控制器上呈现整个屏幕视图控制器

[英]Present a whole screen view controller over a modal view controller

I've got an iPad app which presents a modal view controller over the main view controller. 我有一个iPad应用程序,该应用程序在主视图控制器上显示了一个模态视图控制器。

In the modal view controller, there is an image. 在模态视图控制器中,有一个图像。

┌─────────────────────────────────┐
│                                 │
│      main VC in background      │
│                                 │
│      ┌───────────────────┐      │
│      │  ┌─────────────┐  │      │
│      │  │             │  │      │
│      │  │    Image    │  │      │
│      │  │             │  │      │
│      │  │             │  │      │
│      │  └─────────────┘  │      │
│      │                   │      │
│      │     Modal VC      │      │
│      │                   │      │
│      │                   │      │
└──────┴───────────────────┴──────┘

I want to be able to click the image to zoom the image to the size of the WHOLE SCREEN. 我希望能够单击该图像以将图像缩放到整个屏幕的大小。

If I present the Zoom View Controller from the Modal View Controller, then it will retain the same size as the modal view: 如果我从模态视图控制器中显示缩放视图控制器,则它将保留与模态视图相同的大小:

┌─────────────────────────────────┐
│                                 │
│      main VC in background      │
│                                 │
│      ┌───────────────────┐      │
│      │                   │      │
│      │                   │      │
│      │       Image       │      │
│      │                   │      │
│      │                   │      │
│      │                   │      │
│      ├───────────────────┤      │
│      │                   │      │
│      │     Modal VC      │      │
│      │                   │      │
└──────┴───────────────────┴──────┘

...and if I try to present the Zoom View Controller from the Main View, I will get this error: ...如果我尝试从主视图中显示“缩放视图控制器”,则会收到此错误:

Warning: Attempt to present ZoomViewController on MainViewController which is already presenting ModalViewNavigationController

So what is the correct way to present a whole screen view controller over a modal view controller? 那么在模态视图控制器上呈现整个屏幕视图控制器的正确方法是什么?

Present on the top most modal vc using the OverFullScreen presentation style. 使用OverFullScreen演示样式在最顶层的模态vc上呈现。 Basically present another modal from an already modally presented vc. 基本上从已经模态呈现的vc呈现另一个模态。 It should be your ModalViewNavigationController? 应该是您的ModalViewNavigationController吗?

What you want to do may not be possible. 您可能无法做。 But you could work around it. 但是您可以解决它。

Do you really need to present modally at all? 您真的需要模态呈现吗? If there's nothing in main VC which a user can interact with, just present "modal VC" non-modally. 如果主VC中没有用户可以与之交互的内容,则只需非模式地显示“模式VC”即可。

But if you do need to prevent users interacting with main VC's other views, you could first place a transparent view over it which covers the screen, preventing any interaction with the other views behind. 但是,如果确实需要阻止用户与主VC的其他视图进行交互,则可以先在其上放置一个覆盖屏幕的透明视图,以防止与后面的其他视图进行任何交互。 Then present "modal VC" non-modally in front of that, and then your full screen image in front again. 然后在其前面非模态显示“模态VC”,然后再次在前面显示全屏图像。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM