Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to get UIAutomation iOS UILabel value

I am trying to get the value "HELLO" of the UILabel shown in the iPad simulator. I have enabled accessibility and have set the label as "Label Access". But when I call target.logElementTree(), both the name and value are set to "LabelAccess" and as far as the apple docs say, the value field should contain the string that is set (in this case "Hello"). Does anybody know a fix for this?

PS: I am using the latest iOS SDK and Xcode. Apple Stack Exchange

Output of target.logElementTree();

iPad screen

Accessibility Label

like image 495
i_raqz Avatar asked May 04 '12 14:05

i_raqz


1 Answers

I think you encountered a UIAutomation bug that exists since forever.

Easiest way to get around this bug is to set the accessibilityValue to your text in code.

Something like this.

NSString *valueString = [NSString stringWithFormat:@"%d", value];
self.label.text = valueString;
self.label.accessibilityValue = valueString;

Helps those people that use Voice Over too ;-)

like image 114
Matthias Bauch Avatar answered Nov 19 '22 01:11

Matthias Bauch