Accessible time labels on iOS

大兔子大兔子 提交于 2019-11-30 22:06:48

问题


I am trying to make my iPhone app accessible. Part of it involves generating accessible VoiceOver labels for the time and date parts of an NSDate. How do I format an NSDate in an accessible way that will work correctly in all languages that VoiceOver supports?


回答1:


NSDateFormatter has a method called localizedStringFromDate:dateStyle:timeStyle: that handles the localization automatically. Pass it a date and NSDateFormatterStyles for each the date and time portions. Note that you may want different styles for the date and time if you want something that reads nicely with voiceover. NSDateFormatterLongStyle works well for the date in most cases (as you get the month fully spelled out), while NSDateFormatterShortStyle works well for the time (as it doesn't include seconds).

More information: https://developer.apple.com/library/ios/documentation/Cocoa/Reference/Foundation/Classes/NSDateFormatter_Class/Reference/Reference.html#//apple_ref/occ/clm/NSDateFormatter/localizedStringFromDate:dateStyle:timeStyle:




回答2:


Dates and numbers must be well formatted to be perfectly understood by the VoiceOver users.

Use the following elements below and take a look at some code snippets (Objc + Swift) to figure out how to implement an impeccable read out.



来源:https://stackoverflow.com/questions/13418641/accessible-time-labels-on-ios

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!