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 form
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:
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.