3

I have a text based app where I want my users to make use of the 'Lines' rotor option when VoiceOver is enabled. However the option doesn't appear. The text in my app is laid out using cells in a tableview (the cells contain UILabels and other views).

I'm afraid my implementation affects how the rotor is "seeing" my app, but I think it's unfortunate if it limits me from supporting the rotor fully.

Is there any way I can make use of the 'Lines' option in the rotor?

Mikkel Selsøe
  • 1,171
  • 1
  • 11
  • 23

1 Answers1

3

I think you are looking for the UIAccessibilityReadingContent protocol.

The UIAccessibilityReadingContent protocol can be implemented on an object that represents content that is intended to be read by users, such as a book or an article.

There are four methods to implement:

  • accessibilityLineNumberForPoint:
  • accessibilityContentForLineNumber:
  • accessibilityFrameForLineNumber:
  • accessibilityPageContent

You are going to have to figure out how to cut the text into lines, the frame of each line and what line a certain point belongs to (hit testing) but since you are using table views you should be able to hook into the frames of the cells to figure out those things.

David Rönnqvist
  • 56,267
  • 18
  • 167
  • 205
  • That certainly seems to be what I'm looking for. Unfortunately it seems to be quite painful to calculate line numbers, line frames etc. using standard UIKit components. It seems possible with CoreText or TextKit, but that would require me to completely redesign my implementation. Good ideas are welcome :) – Mikkel Selsøe Apr 02 '14 at 08:45
  • @Miki Weren't you using one table view cell for each line? – David Rönnqvist Apr 02 '14 at 08:55
  • No, one tableviewcell per section of text. Currently I use UILabels with multiple lines of text each. With relative ease, I'd be able to switch to UITextViews for instance. I think that would make it somewhat easier since I then have access to TextKit (I only support iOS 7 and up). – Mikkel Selsøe Apr 02 '14 at 09:01
  • 1
    I've asked this as a separate question (having figured some of it out): http://stackoverflow.com/questions/22807959/get-line-information-from-uitextview-and-nslayoutmanager – Mikkel Selsøe Apr 02 '14 at 10:04