7

I have a table with cells that the user may swipe to mark them "completed". I am trying to make this accessible using VoiceOver by implementing the accessbilityScroll method.

This works fine, but I can't figure out what cell has focus when the user scrolls.

I only find information on how to change focus.

bobmoff
  • 2,415
  • 3
  • 25
  • 32

3 Answers3

11

Hehe, Ok. I just figured it out.

There is a protocol for this. Its called UIAccessibilityFocus

Method: accessibilityElementDidBecomeFocused:

Well, I will leave this question here to any one else that is out there struggling with this.

Mobile Developer
  • 5,730
  • 1
  • 39
  • 45
bobmoff
  • 2,415
  • 3
  • 25
  • 32
  • 1
    I also created a category on UIView, and override the function in there. This provides a nice global callback which gets hit every time the state changes. See my answer here http://stackoverflow.com/a/40914451/1532838 – Harry Bloom Dec 01 '16 at 15:29
  • what is the equivalent of this API in macOS/OSX. I need to know which element is currently focused by Accessibility. Based on the focused element i want to write some logic. – Ananth Kamath Jul 24 '22 at 07:29
  • @AnanthKamath I havent worked with iOS in 10 years and I have never worked with macOS so my your guess is as good as mine – bobmoff Jul 24 '22 at 13:42
4

Your program can also tell where VoiceOver’s “focus” (the object that it’s dealing with) is, and when “focus” enters or leaves any given object.

For Focus Information click here

– accessibilityElementDidBecomeFocused

– accessibilityElementDidLoseFocus

– accessibilityElementIsFocused
Mobile Developer
  • 5,730
  • 1
  • 39
  • 45
Gaurav Borole
  • 796
  • 2
  • 13
  • 32
  • 1
    Yes, it is part of the protocol UIAccessibilityFocus, which I mentioned in my own answer. Isnt your answer the same as mine ? – bobmoff Feb 07 '14 at 10:15
2

As of iOS9, you can use

UIAccessibilityFocusedElement(UIAccessibilityNotificationVoiceOverIdentifier)

https://developer.apple.com/documentation/uikit/1615119-uiaccessibilityfocusedelement

lsw
  • 351
  • 1
  • 4