Post

Replies

Boosts

Views

Activity

Reply to SwiftUI - Determining Current Device and Orientation
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.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Oct ’23
Reply to Metal default library not found
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.
Topic: Graphics & Games SubTopic: General Tags:
Sep ’23
Reply to SwiftUI - Determining Current Device and Orientation
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.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Oct ’23
Reply to Metal default library not found
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.
Topic: Graphics & Games SubTopic: General Tags:
Replies
Boosts
Views
Activity
Sep ’23
Reply to Xcode freezes after upgrade to 12.3
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
Replies
Boosts
Views
Activity
Mar ’21