Hi, I wrote a simple auto layout constraint below and used a force change orientation method to present a full-screen landscape view controller.
imageView.topAnchor.constraint(equalTo: safeAreaLayoutGuide.topAnchor, constant: 16)
After the landscape view controller is dismissed, the safe area guide seems broken, the top safe area insets change to zero, and call layoutIfNeeded() won't fix this issue. The only way to fix this is back to Home Screen and reopen the app. This problem occurred on the iPhone SE simulator, newer devices with a notch don't have this issue. Does anybody know how to fix this?
func forceOrientation(orientation: UIInterfaceOrientation) {
let value = orientation.rawValue
if #available(iOSApplicationExtension 16.0, iOS 16.0, *) {
let windowScene = UIApplication.shared.connectedScenes.first as? UIWindowScene
var interfaceOrientations: UIInterfaceOrientationMask = []
switch orientation {
case .portrait:
interfaceOrientations = .portrait
case .landscapeLeft:
interfaceOrientations = .landscapeLeft
case .landscapeRight:
interfaceOrientations = .landscapeRight
case .portraitUpsideDown:
interfaceOrientations = .portraitUpsideDown
case .unknown:
interfaceOrientations = .portrait
@unknown default:
interfaceOrientations = .portrait
}
windowScene?.requestGeometryUpdate(.iOS(interfaceOrientations: interfaceOrientations))
} else {
UIDevice.current.setValue(value, forKey: "orientation")
UINavigationController.attemptRotationToDeviceOrientation()
}
}
Post
Replies
Boosts
Views
Activity
UIButton automatically obtains a hover highlight effect in visionOS, but both the highlighted area and the corner radius cannot be customized.
I have attempted to modify the range and corner radius of UIPointerInteraction, but it does not work for visionOS.
Regarding UIView, I have reviewed the documentation and it seems that there is no relevant API.
Anybody know how to custom UIButton/UIView hover effect?
Hey everyone, does anybody know how to open the customize menu in iOS 18 beta 3 simulator? This button seems dead.
I've tried, but none of this has had any effect.
Restart simulator and Xcode
Restart MacBook (M2 chip)
Erase simulator
Remove simulator and create a new one
https://drive.google.com/file/d/1XZ0bMvmuTEPPBYznq03MmsnwPL75kzIV/view?usp=sharing