swiftuixcode15

Did previewInterfaceOrientation() stop working in Xcode 15?


I was looking for how to change the orientation of the preview in Xcode 15 and found this SO question, however this is not working for me (I'm using 15.0.1 - 15A507). Has this changed in Xcode 15? Is there another method to change the preview orientation to landscape?

My preview code looks like:

#Preview {
    ContentView()
        .previewInterfaceOrientation(.landscapeLeft)
}

and this is not producing any change to the preview orientation in Xcode 15.


Solution

  • It was changed to traits, try this:

    #Preview(traits: .landscapeLeft) { //<- here
        ContentView()
            //.previewInterfaceOrientation(.landscapeLeft) //<- no longer work
    }