今天在编写测试脚本的时候需要通过 app 弹出的一个 UIAStaticText 进行下一步的判断,但老是获取不到它的 value,然后查了一下,分享一下解决办法:
http://stackoverflow.com/questions/7688311/cant-get-value-of-uiastatictext
interface UILabel (MyAccessibility)
@property(nonatomic, copy) NSString *accessibilityValue;
@end
@implementation UILabel (MyAccessibility)
@dynamic accessibilityValue;
-(NSString *) accessibilityValue {
// Here we force UIKit to return Label value, not the accessibility label
return self.text;
}
@end
加个 catagory