4

Is there any way to decide which element gets focus first? I tried use the second parameter in the following method

UIAccessibilityPostNotification(
    UIAccessibilityLayoutChangedNotification, 
    element
)

but with no success.

shim
  • 9,289
  • 12
  • 69
  • 108
Joris Weimar
  • 4,783
  • 4
  • 33
  • 53
  • 1
    Are you sure that the `element` is an accessibility element? If so, could you post some more information about the problem so that we can help you. `UIAccessibilityPostNotification( ... );` works for me. – David Rönnqvist Mar 25 '13 at 11:24
  • Also, if there is a screen change (major) instead of a layout change (minor) then you should post `UIAccessibilityScreenChangedNotification` instead. – David Rönnqvist Mar 25 '13 at 13:10
  • Sorry, I don't remember exactly. I think the solution was of the kind where you just try all permutations and hope for the best... :) – Joris Weimar Feb 16 '23 at 15:14

1 Answers1

1

Using the UIAccessibilityPostNotification method is the proper way to get your purpose.

There are several types of change notifications but the two most commonly used are :

  • UIAccessibilityLayoutChangedNotification : notifies that a part of the page has changed with 2 possible incoming parameters (a NSString or a UIObject). With a NSString, the notification behaves like a UIAccessibilityAnnouncementNotification with a VoiceOver vocalization. With a UIObject, focus is shifted to the user interface element. This notification is very similar to the UIAccessibilityAnnouncementNotification but should come as a result of dynamic content being deleted or added to the current view.
  • UIAccessibilityScreenChangedNotification : notifies that the whole page has changed including nil or a UIObject as incoming parameters. With nil, the first accessible element in the page is focused. With a UIObject, focus is shifted to the specified element with a VoiceOver. This notification comes along with a vocalization including a sound like announcing a new page.

Your problem may be the element type you specify in your line of code apparently because it seems perfectly correct.

XLE_22
  • 5,124
  • 3
  • 21
  • 72