0

When presenting a UIViewController modally after iOS 13, the presentingViewController gets pushed down to also look like a view in the stack like seen in this image:

Standard Modal Presentation

But in Apple Maps, for example, this does not happen. The presentingViewController stays full screen:

Apple Maps Modal Presentation

I would like to achive the same modal presentation style as in Apple Maps. Has anyone got this working?

I have obviously searched stack overflow and the entire web, looked at every property on UIViewController and UISheetPresentationController, tried setting the modalPresentationStyle of the presentingViewController to fullScreen and overFullScreen (which I rightly assumed before trying wouldn't work).

Jann Thomas
  • 122
  • 6
  • 1
    FYI - you are not the first [to ask this question](https://stackoverflow.com/questions/69408505/how-is-it-possible-when-opening-a-uisheetpresentationcontroller-the-viewcontrol). – HangarRash Mar 04 '23 at 17:13
  • 1
    And [here's another](https://stackoverflow.com/questions/74783279/uisheetpresentationcontroller-displaying-differently-on-different-phones) with a (hacky) solution. – HangarRash Mar 04 '23 at 17:16
  • Thank you so much @HangarRash, I have been searching for questions like this for so long! I don't really have a problem with using a hacky solution in general, the problem with this one is: if you have a text input on the presented sheet, activating that text input sadly breaks the hack and makes the view controller look like it does in my first example image again :/ Then agin, go ahead and answer with your links and I will make that the accepted answer I guess. At this point, I think, without using two UIWindows or something this will not be possible :/ – Jann Thomas Mar 04 '23 at 18:36

2 Answers2

0

The correct answer to this question sadly seems to be that there is no way to do this without either completely reimplementing UISheetPresentationController or presenting it on another UIWindow.

Thanks to @HangarRash, I found out that there is a workaround that works 90% of the time though: Instead of adding the .large() detent, adding a detent with a ever so slightly smaller value makes the view look like it does in Apple Maps:

UISheetPresentationController.Detent.custom(identifier: "almostLarge") { context in
    return context.maximumDetentValue - 0.1
}

The only downside to this is that it does not solve the unwanted UI behaviour when a text input is selected inside of the sheet. For the span of time where it is selected only, the sheets will look like they do in my first image again.

Jann Thomas
  • 122
  • 6
-1

If you try to present myViewController try to put this before navigationController.preset:

myViewController.modalPresentationStyle = .fullScreen

This shoud present your VC on full screen.

Mastertrap
  • 59
  • 1
  • 11
  • 1
    This does not answer my question. This answers the question of **presenting** the present**ED** view controller in full screen, while I am searching for a way to **leaving** the present**ING** view controller full screen. – Jann Thomas Mar 04 '23 at 12:20