In fact, few users know,ios system is actually a complete set of easy access mechanism,Many blind or visually impaired users prefer to useiphone。
So,As a developer,I think both in terms of product sales or as a side responsibility,We should do well to easily access support。
Fortunately, however,,Thanks to Apple's strict development standards,It is generally as long as your app can be added to already approved,So basically VoiceOver It has been able to identify most of your app in the,More generic,For example tabView,such as navigationController,These general frameworks have the automatic support of。Now,We take a look,How to make good use of your app VoiceOver All the advanced features,These features allow you to control to some extent VoiceOver,To make it more compatible with your app,Allowing users to experience better perfect。
main target
VoiceOver can read the contents of the screen in addition to outside,In fact, content can do more,For example, to interact with the interface,For example, the built-in magic pat,Magic Returns,We make customized content to support it,We need to rewrite their own corresponding methods,Let us also own custom buttons,The way you want to operate - after all use VoiceOver users is by listening,So sometimes we also need to add more buttons, etc. to explain,Even,After some action,Also have VoiceOver read specific content to tell the user what happened,These are standardized,So visually impaired users can easily use the app you developed。
VoiceOver running state
To be VoiceOver support,So too we must first be able to find its status - although in fact in most cases you do not need to do,Because you do more configuration for VoiceOver,If VoiceOver is not open, then,Would not have any effect,But if you want to detect what words,In UIKit has a corresponding global function:
1 |
var isVoiceOverOn:Bool {return UIAccessibilityIsVoiceOverRunning()} |
of course,You can also do not like me in one package,I was to own the whole code look more consistent Bale。
Setting readable
For a custom control,You need to manually specify whether you want it as a control VoiceOver:
1 |
someButton.isAccessibilityElement = true |
Control Role
ios for the controls provide some common characters can be configured,Such as a button,For example, the volume keys,Set the appropriate role for the proper control of your control,This helps you control VoiceOver provides additional functionality corresponding。
for example,For keyboard buttons,Necessary to remove the button button while using the keypad buttons character roles,Only in this way,Users can be achieved by sliding your finger on the keyboard,Then when you need to find the button,Release your finger pressed to perform the operation immediately。
1 |
accessibilityTraits = UIAccessibilityTraitKeyboardKey |
of course,In fact, these roles can be more than,We can see this type of role is actually a large integer adoption of the final declaration: public typealias UIAccessibilityTraits = UInt64 So we can:
1 |
accessibilityTraits = UIAccessibilityTraitKeyboardKey | UIAccessibilityTraitButton |
Here is the way I translate what we declared in the translation,Specific features we all need to try。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
// 不使用角色,在某些情况下很有用,比如你想自己处理它的时候,落格输入法的候选字,既想让它有按钮的动作,又不想让它读出来“按钮”这个烦人的提示,那么就用这个了。 public var UIAccessibilityTraitNone: UIAccessibilityTraits // 如果是系统拖的按钮,那么默认肯定就是这个。如果你给按钮的 VoiceOver title 设定的名字是xx按钮,那么VO就不会给你追加“按钮”俩字。 public var UIAccessibilityTraitButton: UIAccessibilityTraits // 控件被用于链接的时候使用 public var UIAccessibilityTraitLink: UIAccessibilityTraits // 控件作为内容的标题的时候使用,比如说导航栏的标题。 @available(iOS 6.0, *) public var UIAccessibilityTraitHeader: UIAccessibilityTraits // 搜索栏 public var UIAccessibilityTraitSearchField: UIAccessibilityTraits // 图片,可以和按钮、链接之类的混合使用。 public var UIAccessibilityTraitImage: UIAccessibilityTraits /* 被选中的控件。 比如说tableview里被选中的那一行。 */ public var UIAccessibilityTraitSelected: UIAccessibilityTraits // 当控件自身可以播放声音的时候 public var UIAccessibilityTraitPlaysSound: UIAccessibilityTraits // 当控件是键盘按钮的时候 public var UIAccessibilityTraitKeyboardKey: UIAccessibilityTraits // 不能改变的静态文本 public var UIAccessibilityTraitStaticText: UIAccessibilityTraits /* 当作为提供当前情况快速总结的时候。 比如说,一个天气应用,第一次打开时当天的天气情况就可以标记为这个。 */ public var UIAccessibilityTraitSummaryElement: UIAccessibilityTraits // 控件不可用的时候 public var UIAccessibilityTraitNotEnabled: UIAccessibilityTraits /* 当控件要频繁地更新其label或者值的时候 比如说秒表。 */ public var UIAccessibilityTraitUpdatesFrequently: UIAccessibilityTraits /* 当控件启动不应该被VO干扰的媒体会话的时候(比如说播放电影,录音) */ @available(iOS 4.0, *) public var UIAccessibilityTraitStartsMediaSession: UIAccessibilityTraits /* 当控件可以被“调节”的时候,比如说滑动条。 控件也要实现 accessibilityIncrement 和 accessibilityDecrement. */ @available(iOS 4.0, *) public var UIAccessibilityTraitAdjustable: UIAccessibilityTraits // 当控件需要直接与用户交互的时候使用,比如说钢琴键盘。 @available(iOS 5.0, *) public var UIAccessibilityTraitAllowsDirectInteraction: UIAccessibilityTraits /* 通知VO完成阅读时要滚动到下一个页面。VO会调用 accessibilityScroll: with UIAccessibilityScrollDirectionNext 并且在检测到内容不变时停止。 */ @available(iOS 5.0, *) public var UIAccessibilityTraitCausesPageTurn: UIAccessibilityTraits /* Used when a view or accessibility container represents an ordered list of tabs. The object with this trait should return NO for isAccessibilityElement. */ @available(iOS 10.0, *) public var UIAccessibilityTraitTabBar: UIAccessibilityTraits |
Magic pat
This is a very common gesture,Is double-click with two fingers on the screen。For example, in off grid input method,It is used to quickly return to the first candidate (when you turn back for a long time)。If you want to monitor this action,He was overridden in the corresponding Controller accessibilityPerformMagicTap :
1 2 3 |
override func accessibilityPerformMagicTap() -> Bool { ... } |
return true To tell the system,VoiceOver receiving operation,return false Skip to illustrate,Send content to other recipients。
Magic Returns
Magic returned the gesture a bit difficult,But a little practice should not be a difficult thing,In short,In places such as navigationController able to return in two fingers back and forth about what is to perform a magic returns。Or by falling input method, for example sub-grid,So magic is performed on the keyboard to return to hide keyboard:
1 2 3 4 |
override func accessibilityPerformEscape() -> Bool { dismissKeyboard() return true } |
Manually alert
Then,How can the initiative to send content to the user prompts it? For example, "the keyboard to enter the expression"? Then you can do:
1 |
UIAccessibilityPostNotification(UIAccessibilityAnnouncementNotification, "进入表情键盘"); |
So VO will read your content after you call it sends a notification,so,Remember to do localization。
The same time,It is worth mentioning that,If you send multiple notifications simultaneously,Then the notification back to the front of the notification will be overwritten! For example, this:
1 2 3 |
UIAccessibilityPostNotification(UIAccessibilityAnnouncementNotification, "进入表情键盘"); UIAccessibilityPostNotification(UIAccessibilityAnnouncementNotification, "进入符号键盘"); UIAccessibilityPostNotification(UIAccessibilityAnnouncementNotification, "进入拼音键盘"); |
Then you get it is likely to be "keyboard to enter the expression" or "keyboard to enter Pinyin",The other two are lost。
For example, in Georgia there before falling input method version,There has been a bug,That's the word can not be read in VO deleted。For visually impaired users this is a very important issue,Because if you do not read it if they are not sure what is deleted,It is really terrible。And worse than this,My own local test is completely normal!
So,We must pay attention to this issue,Send notification does not necessarily have to be in the main thread (if you're like me, then common concurrent),But be sure to pay attention to spacing,After analysis,Eventually I came to understand,When you click delete on your keyboard,Then as a third-party keyboard,I must call to remove the built-api,But this will delete trigger UI changes (because the text has changed, right?) VoiceOver will go innocently report the cursor position,Obviously,Usually mistyped the last word is certainly the majority,So naturally bug it would read "text at the bottom."。
At this moment,Just notice slower than the system just fine,(Notification system than you want to slow down hair,So it is always covered my notice even if I put it deleted after the call),so,I like this deal:
1 2 3 |
DispatchQueue.global().asyncAfter(deadline: DispatchTime.now() + 0.1, execute: { UIAccessibilityPostNotification(UIAccessibilityAnnouncementNotification, String(word.characters.last!)); }) |
In short,So slow 0.1 seconds for the user they can not find any difference,However, for the system,,That is, with enough time for VO receipt notification system,We had a chance to read your notification was given overwritten。
Manually change focus
When the user clicks the keyboard,After doing some operations or,We need to let the VO automatically move the focus to the top,A typical case is that you click on the button keyboard,Candidate column will update new candidate word,This time the focus is moved to speak first candidate will be very easy to use。Because in that case,Users can double-click on the screen to select it directly。so,I do it this way:
1 |
UIAccessibilityPostNotification(UIAccessibilityLayoutChangedNotification, self); |
The second parameter is the actual control to get the focus of a reference,After this notification,VO will immediately move the focus to and read out its contents on this space。
Summarize
Basically,For VoiceOver test,You can not be completed in xcode,Tool that comes with it can only support the easiest way to check,Want to test your complete support VO,You should install the app on your iphone,Then open VoiceOver,Close your eyes and go personally used some,If you are not good at VoiceOver can successfully use your app,That should be no big problem。
all above,I was made to drop the grid input ios platform VoiceOver support life experience the best of the Chinese input method。?
Original article written by LogStudio:R0uter's Blog » ios VoiceOver support for visually impaired users
Reproduced Please keep the source and description link:https://www.logcg.com/archives/2322.html
Comments