I'm trying to listen for changes on the Prefers Cross-Fade Transitions accessibility option using UIKit in Objective-C, but for some reason UIAccessibilityPrefersCrossFadeTransitionsStatusDidChangeNotification
does not get triggered when I toggle this option in the accessibility settings, I've tested both using the simulator and a real device running iOS 16.0, it seems that this never worked since it was first introduced on iOS 14.0
According to the docs this should be fine https://developer.apple.com/documentation/uikit/uiaccessibilitypreferscrossfadetransitionsstatusdidchangenotification?language=objc
Here is a little snapshot of the code I'm using
- (void)prefersCrossFadeTransitionsStatusDidChange:(__unused NSNotification *)notification
{
NSLog(@"Prefers Cross-Fade Transitions changed");
}
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(prefersCrossFadeTransitionsStatusDidChange:)
name:UIAccessibilityPrefersCrossFadeTransitionsStatusDidChangeNotification
object:nil];
Wirdly enough UIAccessibilityPrefersCrossFadeTransitions
returns the correct value when called
I've also tested this using Swift and it does not work either. prefersCrossFadeTransitionsStatusChanged
is never triggered
NotificationCenter.default.addObserver(self, selector: #selector(prefersCrossFadeTransitionsStatusChanged(_:)), name: UIAccessibility.prefersCrossFadeTransitionsStatusDidChange, object: nil) @objc func prefersCrossFadeTransitionsStatusChanged(_ notif: NSNotification) {
print("prefers Cross Fade Transitions Status Changed")
}
Hello, thanks for bringing up this issue. We are aware of this notification not posting as expected and are working to address it.
As a temporary workaround, if you add UIAccessibilityPrefersCrossFadeTransitions()
somewhere in your code (like before adding self as an observer for the notification), it will kickstart the Notification Center and you will start receiving subsequent posts for the Prefers Cross Fade Transitions preference
Here's an example
UIAccessibilityPrefersCrossFadeTransitions()
NotificationCenter.default.addObserver(self, selector: #selector(prefersCrossFadeTransitionsStatusChanged(_:)), name: UIAccessibility.prefersCrossFadeTransitionsStatusDidChange, object: nil)