Search code examples
iosaccessibilityvoiceover

Initial VoiceOver selection


I'm adding VoiceOver support to my app. So far, so good, but I'd really like to be able to specify which element is the first one spoken after a UIAccessibilityScreenChangedNotification. I haven't seen a way to do this. Making something the summary element doesn't really seem to do it. Am I missing something?


Solution

  • This has always been perfectly possible to do.

    Just write something along the lines of:

    - (void)viewDidAppear:(BOOL)animated {
        [super viewDidAppear:animated];
    
        UIAccessibilityPostNotification(UIAccessibilityScreenChangedNotification,
                                        self.myFirstElement);
    }
    @end
    

    This works for both UIAccessibilityScreenChangedNotification and UIAccessibilityLayoutChangedNotification.

    Now for Swift 5

    override func viewDidAppear(_ animated: Bool) {
        UIAccessibility.post(notification: UIAccessibility.Notification.screenChanged,
                             argument: myFirstElement)
    }