简体   繁体   中英

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.

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 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM