2

I am working on an app and trying to make it as accessible as possible. I am trying to move focus to a certain element once an action takes place. I was curious about the difference between these two functions:

UIAccessibilityFocusedElement vs. UIAccessibilityPostNotification

If someone could explain the difference between the two it would be greatly appreciated.

user2603138
  • 1,397
  • 2
  • 10
  • 10
  • This doesn't directly address the difference between the two, but an amazing overview I have starred that might solve your problem and directly relates to `UIAccessibilityPostNotification`: http://stackoverflow.com/questions/27797515/actual-difference-between-uiaccessibilitylayoutchangednotification-and-uiaccessi – bdrelling Jan 27 '17 at 20:09
  • sorry for the late response. yeah didn't really answer the question but did help with my problem. – user2603138 Feb 10 '17 at 19:47

2 Answers2

4

UIAccessibilityPostNotification is used to change things (like focused elements but also pausing and resuming assistive technology like that:

UIAccessibility.post(notification: .pauseAssistiveTechnology, argument: UIAccessibility.AssistiveTechnologyIdentifier.notificationSwitchControl)
UIAccessibility.post(notification: .resumeAssistiveTechnology, argument: UIAccessibility.AssistiveTechnologyIdentifier.notificationSwitchControl)

It can also announce something:

UIAccessibility.post(notification: .announcement, argument: "Say something")

or refresh focus after accessibility scroll

UIAccessibility.post(notification: .pageScrolled, argument: nil)

On the other hand UIAccessibilityFocusedElement can't change anything. It just returns currently focused element (or nil) this way:

UIAccessibility.focusedElement(using: UIAccessibility.AssistiveTechnologyIdentifier.notificationVoiceOver)

On a side note - for now only assistive technology that can be paused or resumed is notificationSwitchControl, trying that with Voice Over causes crashes

Adam Tucholski
  • 1,067
  • 11
  • 27
2

If you are trying to move focus to an element based off an actions / screen change scenario.

I think you should probably take a look at:

UIAccessibilityPostNotification(UIAccessibilityScreenChangedNotification, element_to_be_focused>);

Should be posted when a new view appears that encompasses a major portion of the screen.

or

UIAccessibilityPostNotification(UIAccessibilityLayoutChangedNotification, element_to_be_focused); 

Should be posted when the layout of a screen changes, for example when an individual element appears or disappears.

JMI
  • 2,530
  • 15
  • 26
dashuser
  • 181
  • 1
  • 3
  • 16