[英]How to set the testID and the accessibilityLabel together with React Native?
[英]How to programmatically set accessibilityLabel on UILabel?
我試圖在我的UIViewController中以編程方式設置UILabel(標題為“ Mega Title!”的UILabel)的可訪問性標簽和值。 這是我的viewDidLoad ...
- (void)viewDidLoad {
[super viewDidLoad];
// seems you can only set value on UILabel
self.powLabel.isAccessibilityElement = YES;
self.powLabel.accessibilityLabel = @"lbl label"; // sets value ???
self.powLabel.accessibilityValue = @"lbl value"; // this doesn't work.
// you can set title and value on UIView
self.powView.isAccessibilityElement = YES;
self.powView.accessibilityLabel = @"view label"; // sets title
self.powView.accessibilityValue = @"view value"; // sets value
// you can set title and value on UIButton
self.powButton.isAccessibilityElement = YES;
self.powButton.accessibilityLabel = @"btn label"; // sets title
self.powButton.accessibilityValue = @"btn value"; // this value
}
可訪問性標題/值已在UIView和UIButton控件中正確設置...但是,僅可訪問性值在UILabel控件上已設置。 這是輔助功能檢查器顯示的屏幕截圖...
如何設置UILabel,以便accessibilityLabel實際上具有值?
UILabel將使用.text
作為其上的文本集作為accessibilityLabel,這取決於您要執行的操作,我認為最好使用accessibilityIdentifier
來標識UI元素並保留默認值。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.