iOS 18 SwiftUI sheet resizing from page to form presentation sizing

I'm presenting a UIKit view controller from SwiftUI in a sheet using UIViewControllerRepresentable. The size of the sheet is being set to PagePresentationSizing using the new iOS 18 presentationSizing method.

When Split View is used and the size class changes from regular to compact, the sheet resizes as expected to fit in the smaller window. When the app returns to full screen and the size class changes back to regular, the sheet is now displayed using FormPresentationSizing instead of PagePresentationSizing.

This all worked as expected in iOS 17 with the view controller modalPresentationStyle being specified in the UIViewControllerRepresentable implementation, but the behaviour has now changed with iOS 18.

How do I preserve the desired presentation sizing of the sheet?

Thanks for any help.

You might want to specify how the system adapts the presentation to compact size classes or to horizontal and vertical compact size classes using

presentationCompactAdaptation(horizontal:vertical:) or presentationCompactAdaptation(_:)

Please give that a try, if you need any further help please provide a test project. That'll help us better understand what's going on. If you're not familiar with preparing a test project, take a look at Creating a test project.

The issue isn't with the compact presentation; it occurs when you return from the compact presentation to the regular presentation.

The issue is reproducible in a minimal test project which can be accessed here: https://github.com/da-sysnet/SheetResizingTest

There are three buttons which each present a different sized sheet. Once the sheet is presented, use Split View to move the app into a compact horizontal size class. The sheet will resize as expected and display correctly. Now close split view to return the app to a regular horizontal size class. The sheets using the .form and .custom presentationSizing will return to their original size. The sheet using the .page presentationSizing will change to a different size which appears to use the .page sheet height and the .form sheet width.

iOS 18 SwiftUI sheet resizing from page to form presentation sizing
 
 
Q