Failed to get UIAutomation iOS UILabel Value

I am trying to get the "HELLO" value for UILabel shown in the iPad simulator. I turned on accessibility and 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 Apple docs say, the value field should contain the string that is set (in this case, "HELLO" ). Does anyone know about this?

PS: I use the latest iOS SDK and Xcode. Apple stack exchange

Output of target.logElementTree ();

iPad screen

Accessibility label

+7
source share
1 answer

I think you are facing a UIAutomation error that has existed forever.

The easiest way to get around this error is to set the accessibilityValue value to your text in the code.

Something like that.

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

Helps those people who use Voice Over too; -)

+5
source

All Articles