Unable to get pickerView.tag in -pickerView:accessibilityLabelForComponent: method

自作多情 提交于 2019-12-11 10:40:02

问题


Protocol:

UIPickerViewAccessibilityDelegate

Method:

-pickerView:accessibilityLabelForComponent:

Problem:

Apple Documentation says

- (NSString *)pickerView:(UIPickerView *)pickerView
accessibilityLabelForComponent:(NSInteger)component

But the pickerView which I get inside this method is NOT a UIPickerView*, but is a UIAccessibilityPickerElement, and hence using pickerView.tag inside this method crashes.

I have 2 pickerviews in my view controller and I need to access the tag to identify them.

Question:

How can I provide accessibilityLabel for components of both pickerViews in this method?


回答1:


Maybe this help.

I have a very similar problem with a custom component. I have a pickerView in this component. My was "weak" that's why I couldn't access to tag property.

I had to define a new property to identify each picker.



来源:https://stackoverflow.com/questions/28445598/unable-to-get-pickerview-tag-in-pickerviewaccessibilitylabelforcomponent-meth

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!