Is UIScreen.main.bounds valid on iPhone Duo?

During a fold, UIScreen.main.bounds stays at the outer-display size while window.windowScene?.screen.bounds updates. Layout that still reads UIScreen.main (sheet heights, map padding, title widths) is wrong on the inner display. Should apps stop using UIScreen.main entirely and always read the window scene’s screen?

Answered by DTS Engineer in 912961022

Hi @ios-enthusiastic,

Should apps stop using UIScreen.main entirely and always read the window scene’s screen?

Avoid the main screen. It's ambiguous on a two-display device. Use the environment, trait collection or scene bounds. If you need a screen, get it from the window scene. For more details, watch the following Tech Talk:

Prepare your app for iPhone Duo
https://developer.apple.com/videos/play/tech-talks/111461/

Cheers,

Paris X Pinkney |  WWDR | DTS Engineer

The recommendation is always to use the most local layout information you can use. While reading from a window or its scene's bounds is less problematic than reading from the main screen, if you can get the same information from a specific view in your view hierarchy, that is the guidance that will be given.

Hi @ios-enthusiastic,

Should apps stop using UIScreen.main entirely and always read the window scene’s screen?

Avoid the main screen. It's ambiguous on a two-display device. Use the environment, trait collection or scene bounds. If you need a screen, get it from the window scene. For more details, watch the following Tech Talk:

Prepare your app for iPhone Duo
https://developer.apple.com/videos/play/tech-talks/111461/

Cheers,

Paris X Pinkney |  WWDR | DTS Engineer