Hello!
I found another possible solution. Let me know if it works for you:
import SwiftUI
import Combine
struct OrientationView: View {
@State private var orientation: UIDeviceOrientation? = nil
@State private var orientationChangePublisher: AnyCancellable?
var body: some View {
Text("Hello, World!")
.onAppear {
orientationChangePublisher = NotificationCenter.default.publisher(for: UIDevice.orientationDidChangeNotification)
.compactMap { notification in
UIDevice.current.orientation
}
.sink { newOrientation in
orientation = newOrientation
print("isLandscape: \(orientation?.isLandscape ?? false))")
print("isPortrait: \(orientation?.isPortrait ?? false))")
print("isFlat: \(orientation?.isFlat ?? false))")
}
}
.onDisappear {
orientationChangePublisher?.cancel()
}
}
}
#Preview {
OrientationView()
}
Best regards.
Post
Replies
Boosts
Views
Activity
Hello guys.
If you are working with the latest Xcode 15 and iOS 17, delete derived data, close Xcode (reboot your updated iPhone) and run the app.
You will have to wait a couple of minutes and your app will start working again.
Hopping it will work for you too.
Best regards.
Note: You will get lots of log messages before the screen turns on again.
Hello, you can unpair your network connected devices if you don't want to go back to Xcode 12.2 or lower.
The same response is available here - https://stackoverflow.com/a/65329297/3430658.
Best regards