13

I have a UITableView that I have scroll to the bottom as soon as the user adds another element/table cell to it. For the screen this works fine, because the user can see the cell they just added at the bottom of the table. But when running my app using VoiceOver, the first UITableCell to get focused and read is the top cell that's visible on the screen.

I want to set it so that the cell that gets focused and then read as soon as this UITableView appears is the very last cell in the table. How do I do this? It seems like it would be very simple but I can't figure it out.

Here's what I tried so far (in cellForRowAtIndexPath):

if (cellJustAdded && indexPath.row == [array count]-1) {
    cell.accessibilityElementIsFocused = YES; //obviously this does not work
}

but I don't think you can use accessibilityElementIsFocused like that.

2
  • Okay so I'm pretty sure the answer to this lies somewhere with UIAccessibilityZoomFocusChanged but I can't seem to get it to work.
    – Ginny
    Dec 27, 2011 at 11:33
  • UIAccessibilityZoomFocusChanged is used when the zoom feature is turned on in settings. Mar 28, 2013 at 10:30

1 Answer 1

9

When you want VoiceOver to select a certain element you can post an accessibility notification using UIAccessibilityPostNotification( ... );.

Depending on if it's a major (complete screen) change or a minor (layout only) change you should post either

  • UIAccessibilityScreenChangedNotification (complete change)
  • UIAccessibilityLayoutChangedNotification (small change)

In both cases the optional argument is the element that VoiceOver should move to.

So after having added the new cell to your table view you would call

UIAccessibilityPostNotification(UIAccessibilityLayoutChangedNotification,
                                yourNewCellThatShouldHaveFocus); 
1
  • 2
    This way does not seem to work for me at multiple places. Any guess what might be the reason ?
    – Dynamite
    Aug 7, 2014 at 9:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.