I'm trying to make a UIPickerView of mine Voice Over accessible, I've noticed that the UIPickerViewAccessibilityDelegate protocol is rather incomplete. It only allows you to specify labels and hints for pickerView components, not the rows within the components. (it also has a bug that its pickerView:accessibilityLabelForComponent: method doesn't pass a UIPickerView* in it's pickerView parameter, it's a UIAccessibilityPickerComponent instead!)
So i'm wondering now, is there any way at all to set custom accessibility labels for the rows of my picker, or is it only possible to read out the actual picker row values as displayed on the screen?
I'm trying to do a picker view that shows time on it, hours, minutes, seconds. I couldn't get the datePicker to do this. But it'd be nice if each row could in voice over say something like "3 hours" instead of just 3. If I have to set the visible labels to what I want the voice over to read out then I'm not sure the labels are going to fit to show this, ie.
15 hours 35 minutes 20 seconds
is quite a lot to fit on the screen in english, not sure how big it'll grow when localised.. hence the ideal of being able to set labels for each row.
Cheers
If you are implementing the pickerView:viewForRow:forComponent:reusingView:
method of UIPickerViewDelegate
as the way to populate the UIPickerView components, you can achieve custom accessibility label for each row by setting accessibilityLabel
on the UIView
you are returning from that method.
Note that I wasn't successful at making VoiceOver read custom accessibility label in cases where I populate the UIPickerView
using pickerView:titleForRow:forComponent:
- even setting accessibilityLabel
on the returned NSString
(which does work in some other contexts, like setting accessibility labels for UITableView indexes) did not change what VoiceOver pronounces. So it seems the only way to go if you want to customize what VoiceOver (or Switch Control) speaks for a UIPickerView row is to use pickerView:viewForRow:forComponent:reusingView:
, not any of the other 2 candidate methods, to populate the UIPickerView rows.
However, I still recommend you to reconsider whether what you are doing is desirable. When VoiceOver (or Switch Control) user arrives on the component, say e.g. with accessibilityLabel
"Minutes", they know they are on minutes, because VoiceOver reads e.g. "Minutes, 19", and so when adjusting the value, they don't need to hear again "20 minutes", "21 minutes"; "20" and "21" quite suffices, the user can remember the context (e.g. "now I am on minutes, so let's adjust it to 45").
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With