Crash when changing the accessibilityElements to custom UIAccessibilityElement

I got a UIControl, and I want to make it behavior like a custom UIAccessibilityElement.

UIControl *control = [[UIControl alloc] init];
control.isAccessibilityElement = NO;

CustomAccessibilityElement *elem = [[CustomAccessibilityElement alloc] initWithAccessibilityContainer:control];
elem.isAccessibilityElement = YES;
// some custom setting here

control.accessibilityElements = @[elem];

It worked well with an iPhone 13, iOS 15.5.1, but crashed with an iPhone SE, iOS 15.4.1 and the crash msg is :

"-[UIAccessibilityElement _addAccessibilityElementsAndOrderedContainersWithOptions:toCollection:]: unrecognized selector sent to instance 0x283b7c680"

Can you tell me the reason ?

Thanks a lot.

Answered by Frameworks Engineer in 809293022

Hello, this sounds like a bug we want to investigate. To help us out, please reproduce the crash and then gather system diagnostics using the Feedback Assistant tool: https://developer.apple.com/bug-reporting/

Once you file a report please reply with the feedback ID and I'll make sure the right folks take a look soon.

Accepted Answer

Hello, this sounds like a bug we want to investigate. To help us out, please reproduce the crash and then gather system diagnostics using the Feedback Assistant tool: https://developer.apple.com/bug-reporting/

Once you file a report please reply with the feedback ID and I'll make sure the right folks take a look soon.

Crash when changing the accessibilityElements to custom UIAccessibilityElement
 
 
Q