簡體   English   中英

輔助功能 - UIPickerView 作為 inputView

[英]Accessibility - UIPickerView as inputView

我使用UIPickerView作為UITextField的 inputView 。

self.pickerView = [[UIPickerView alloc]initWithFrame:CGRectZero];

self.pickerView.dataSource = self.datasource;
self.pickerView.delegate = self.delegate;

//additional setups

self.textField.inputView = self.pickerView;

一切正常,但是當我激活畫外音並開始在 itens 中循環時,畫外音開始發出不正確的公告。

我做了一些研究,我在github上找到了一個有同樣問題的人的 repo,但我找不到任何解決方案。

我找到了解決這種情況的方法。 pickerView(_:didSelectRow:inComponent:)方法上,我將UIAccessibilityPostNotificationUIAccessibilityAnnouncementNotification一起使用,傳遞選擇的項目,強制畫外音發出正確的通知。

目標-C:

-(void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component {
    if(UIAccessibilityIsVoiceOverRunning()){
        UIAccessibilityPostNotification(UIAccessibilityAnnouncementNotification, self.items[row]);
    }
}

迅速:

func pickerView(_ pickerView: UIPickerView, didSelectRow row: Int, inComponent component: Int) {
    if(UIAccessibility.isVoiceOverRunning){
        UIAccessibility.post(notification: UIAccessibility.Notification.announcement, argument: self.items);
    }
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM