Reputation: 5883
self.searchbar.isAccessibilityElement=YES;
self.searchbar.accessibilityLabel=@"searchbar";
self.searchbar.accessibilityHint=@"searchbar";
self.searchbar.accessibilityElementsHidden=NO;
The above code i have added for a UISearchbar outlet in ViewDidLoad.Unfortunately accessibility labels are not getting displayed.I used the above code for all UIelements and works fine except for UISearchbar.Do we have to use UIAccessibilityContainer for UISearchbar?
Upvotes: 3
Views: 3051
Reputation: 21
try to add the accessibility label to text field property of searchBar
Upvotes: 2
Reputation:
You need to tell iOS which accessibility trait best characterizes the object. In this case you want:
self.searchbar.accessibilityTraits = UIAccessibilityTraitSearchField;
You may also want to have a look Apple's UIAccessibilityTraits documentation.
Upvotes: 7