endGeneratingDeviceOrientationNotifications not working in iOS 16.7?

90 Views Asked by At

I have an Objective C app that includes an 'orientation lock' switch, that allows users to switch off response to device orientation changes during some functions, so that rotating the device doesn't affect the screen, while allowing normal rotation during other functions.
This has worked fine for 10 years; it still works on iOS 15. However, I've just found that it doesn't work on current iPhones with iOS 16.7 or iPhone simulator with iOS 17: instead, the screen orientation rotates to match the device orientation, when it should be locked.

When users have set the app's orientation lock switch, at the start of a lockable function the app calls

[[UIDevice currentDevice]endGeneratingDeviceOrientationNotifications];

It does it repeatedly until

[UIDevice currentDevice].generatesDeviceOrientationNotifications == NO

I'd expect that there would then be no device orientation notifications, and up to iOS 15 the app's MainViewController viewWillTransitionToSize method and related layout methods are not called when the device rotates. But they are being called in iOS 16 and 17. Is it a bug in iOS? Or has Apple changed something, so I need to change the app code (I've checked Apple developer documentation)?

0

There are 0 best solutions below