Davy Li
Davy Li

Reputation: 603

Voiceover accessibility of UITableView subviews

I currently have a UITableViewController and I'm adding a UIDatePicker as a subview as follows:

self.datePicker = [[UIDatePicker alloc] initWithFrame:CGRectMake(0, 200, 200, 200)];
self.datePicker.datePickerMode = UIDatePickerModeTime;
[self.tableview addSubview:self.datePicker];

which is ran in viewDidLoad.

The issue is that the UIDatePicker doesn't show up as an accessible element, and does not read out the current date and time with VoiceOver turned on. I have tried disabling accessibilityElementsHidden setting of the tableview, but that also disables the subview's accessibility. Effectively, if I can disable the accessibility of the UITableView when the UIDatePicker is selected, then it would work.

Note: The UITableViewCells do not overlap the UIDatePicker.

Upvotes: 1

Views: 6561

Answers (1)

Aaron Brager
Aaron Brager

Reputation: 66302

UITableView isn't designed to have subviews added directly to it. It implements the UIAccessibilityContainer informal protocol and provides accessibility elements to VoiceOver users, coordinating with the table view's delegate.

To resolve this, instead of adding subviews directly to the table view, add your picker view to a cell's contentView, a table section header/footer, or a table header/footer.

For more, see Enhance the Accessibility of Table Views.

Upvotes: 3

Related Questions