简体   繁体   中英

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.

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. Basically present another modal from an already modally presented vc. It should be your 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.

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. Then present "modal VC" non-modally in front of that, and then your full screen image in front again.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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