Skip to content

Latest commit

 

History

History

FB13769795

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 

Xcode canvas device orientation is reported as unknown

Basic Information

Which area are you seeing an issue with?

Simulator

What type of feedback are you reporting?

Incorrect/Unexpected Behavior

Details

Did you see an error message?

No

What time did the issue occur?

1 May 2024 at 21:14

What devices were you using when the issue occurred?

iOS or iPadOS device

Description

  • Run the given code.
  • Use canvas / Xcode previews / SwiftUI previews.
  • See orientation is unknown.
  • In some cases, the orientation may not be reported as unknown. However, after a canvas refresh, it can become unknown again. When switching to one of the landscape orientations, sometimes it may be the correct orientation, and then become unknown when the canvas is refreshed again.

Evidence

Visual

Demo Workaround
Demo PNG Unknown

Code

import SwiftUI
struct ContentView: View {
var body: some View {
Text("Orientation is unknown: \(isUnknown)")
}
private var isUnknown: Bool {
UIDevice.current.orientation == .unknown
}
}
#Preview {
ContentView()
}