[英]Accessibility tab order for iOS keyboard with custom UI button
我正在使用一個Cordova應用程序,該應用程序的屏幕帶有需要十進制iOS鍵盤的輸入文本字段。
我無法從JavaScript代碼中找到一種自然的方式來顯示iOS鍵盤(只有數字和一個句點)。
因此,我使用了cordova插件( https://github.com/mrchandoo/cordova-plugin-decimal-keyboard ),該插件使用輸入屬性pattern =“ [0-9] *”來顯示數字鍵盤(不包含十進制)並創建一個自定義UI按鈕,並將其放置在空白處。
在我開始測試該組件的可訪問性之前,它實際上對我來說非常有效。
當您在VoiceOver模式下切換(即滑動)時,無法訪問該按鈕。
有什么辦法可以操縱iOS的跳位順序並插入可訪問性元素?
這是(簡化的)混合代碼: <input type="text" pattern="[0-9]*" decimal="true">
這是(簡化的)本地代碼段:
decimalButton = [UIButton buttonWithType: UIButtonTypeCustom];
[self setDecimalChar];
[decimalButton setTitleColor:[UIColor colorWithRed:0/255.0 green:0/255.0 blue:0/255.0 alpha:1.0] forState:UIControlStateNormal];
decimalButton.titleLabel.font = [UIFont systemFontOfSize:40.0];
[decimalButton addTarget:self action:@selector(buttonPressed:)
forControlEvents:UIControlEventTouchUpInside];
[decimalButton addTarget:self action:@selector(buttonPressCancel:)
forControlEvents:UIControlEventTouchUpOutside];
decimalButton.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter;
[decimalButton setTitleEdgeInsets:UIEdgeInsetsMake(-20.0f, 0.0f, 0.0f, 0.0f)];
[decimalButton setBackgroundColor: [UIColor colorWithRed:210/255.0 green:213/255.0 blue:218/255.0 alpha:1.0]];
// locate keyboard view
UIWindow* tempWindow = nil;
NSArray* openWindows = [[UIApplication sharedApplication] windows];
for(UIWindow* object in openWindows){
if([[object description] hasPrefix:@"<UIRemoteKeyboardWindow"] == YES){
tempWindow = object;
}
}
UIView* keyboard;
for(int i=0; i<[tempWindow.subviews count]; i++) {
keyboard = [tempWindow.subviews objectAtIndex:i];
[self listSubviewsOfView: keyboard];
decimalButton.frame = cgButton;
[ui addSubview:decimalButton];
任何幫助將不勝感激。 謝謝!
首先想到的是,自定義十進制按鈕可能不會自動設置為可訪問性元素,這意味着VoiceOver將無法與其進行交互。
最簡單的測試方法是添加
[decimalButton setIsAccessibilityElement:YES];
到上面的本機代碼。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.