I am writing an app for people with blindness and would like to put some instruction on its home page. The instruction is a multi-paragraph static text piece. I put it in a UITextView.
I would like blind users to be able to read the instruction paragraph by paragraph using VoiceOver. However, when users move VoiceOver focus onto the UITextView, VoiceOver always read the instruction as a whole piece. My devices are iPad 2 and iPhone 5s with iOS 7.
So, is there any way I can set up my UITextView so that VoiceOver users can read the text piece paragraph by paragraph? If that is impossible with a UITextView, what are some other options? Do I really have to use a UITableView?
Thank you!
Joe
VoiceOver users, not you, determine how much text is read at once. You could override this by subclassing UITextView
and implementing the UIAccessibilityContainer
informal protocol. However, this would be unintuitive for VoiceOver users so I recommend you avoid it. Some VoiceOver users can listen to lots of text read extremely quickly, and it would be frustrating for them if you artificially forced the reading to stop between paragraphs.
TTTAttributedLabel
, an open-source label library that supports hyperlinking, overrides these methods to make links accessible. You may wish to review the relevant source code if you decide to proceed with this implementation against my advice.
The easiest solution : just a rotor item to be selected and used when appropriate.
VoiceOver users know this gesture, the only thing to be done by the developper is a perfect formatting of the UITextView content.
I created a blank application with the code snippet hereafter :
class TextViewURLViewController: UIViewController, UITextViewDelegate {
@IBOutlet weak var myTextView: UITextView!
let myString = """
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam vel vulputate purus. Vivamus imperdiet efficitur orci, eu dictum lorem rutrum nec. Quisque sed dui nec mauris pulvinar ultricies a et ex. Cras dapibus, ipsum sit amet facilisis laoreet, velit sapien dapibus ex, sed tempor lacus nulla ac neque. Donec eu sagittis risus. Nunc commodo quis dolor iaculis eleifend. Suspendisse justo nunc, fermentum a maximus at, viverra in velit. Vivamus eu efficitur velit. Interdum et malesuada fames ac ante ipsum primis in faucibus. Phasellus et porta justo. Proin dui lacus, fringilla sit amet est eu, lacinia vulputate ante. Nulla sodales condimentum ornare. Integer sollicitudin augue metus, lobortis mollis ligula tempor at.
Sed cursus feugiat dolor. Etiam orci odio, semper nec feugiat in, viverra facilisis mauris. Duis dignissim, orci a tincidunt malesuada, ex neque pharetra nibh, venenatis auctor massa nibh sit amet dolor. Curabitur scelerisque suscipit tincidunt. Nunc a sapien consequat, porttitor velit at, fermentum nulla. Aenean lobortis consequat leo ac porta. Praesent fringilla vitae nisl in rhoncus.
Donec sed turpis sed nibh finibus consequat. Pellentesque non nulla fringilla, porttitor elit nec, lacinia turpis. Suspendisse commodo, erat sed volutpat gravida, erat libero maximus urna, ut bibendum justo leo et libero. Donec tempor lorem eget tincidunt consequat. Suspendisse ut pretium est. Suspendisse tristique sollicitudin cursus. Ut pulvinar ultrices euismod. Mauris iaculis facilisis sem, et euismod purus lobortis vel. Maecenas ut nulla diam. Mauris porta fringilla vulputate. Maecenas accumsan, nulla vel elementum laoreet, neque nisl faucibus est, ut varius lorem tellus vel mauris.
"""
override func viewDidLoad() {
myTextView.attributedText = NSMutableAttributedString(string: myString)
}
}
Follow the steps hereunder to read the UITextView content paragraph by paragraph :
- In the 'Accessibility - VoiceOver - Rotor' settings, select the
Lines
item to be displayed automatically when appropriate.
- When your app's on the screen, select the
Lines
item.
- Flick down to get the first paragraph to be read out.
- Flick down to get the next paragraph to be read out.
Now, if you think that the users won't know this gesture (weird but possible), you can :
- Remove your initial UITextView and create as many UITextView as paragraphs so as to allow VoiceOver to select each one of them with a simple flick right or left.
- Use the
UIAccessibilityContainer
protocol by splitting your UITextView content into as many UIAccessibilityElement
as paragraphs you want.
If many pages are at stake, take a look at the UIAccessibilityReadingContent
that should help you to read one page at a time.
Up to you to get the solution that suits you best.