iOS Voiceover status

IosAccessibilityVoiceoverUiaccessibility

Ios Problem Overview


I am trying to add accessibility features to an iOS app that has already been developed.

There are a couple of UI features (e.g. buttons) that I like them to show up if the VoiceOver option in the accessibility menu of the iPhone settings is on and do not show up if the voiceover is off.

Is there a way to check whether the voiceover option is on or not?

Ios Solutions


Solution 1 - Ios

BOOL UIAccessibilityIsVoiceOverRunning();

Solution 2 - Ios

In ViewDIdLoad

[[NSNotificationCenter defaultCenter] addObserver:self
                                         selector:@selector(voiceOverStatusChanged)
                                             name:UIAccessibilityVoiceOverStatusChanged
                                           object:nil];


- (void)voiceOverStatusChanged
{
    if(!UIAccessibilityIsVoiceOverRunning())
    {
        //do your changes
    }
}

Solution 3 - Ios

For Swift 4.2 and newer versions, you can check the following boolean provided by UIKit:

UIAccessibility.isVoiceOverRunning

Solution 4 - Ios

As a supplement to all the previous correct answers, since iOS11 and according to this Accessibility options recap, the new notification name to be used is :

  • UIAccessibilityVoiceOverStatusDidChange (SWIFT < 4.2).
  • UIAccessibilityVoiceOverStatusDidChangeNotification (ObjC).

... while UIAccessibilityVoiceOverStatusChanged is deprecated.

EDIT for SWIFT 4.2 ==> UIAccessibility.voiceOverStatusDidChangeNotification

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionArashView Question on Stackoverflow
Solution 1 - IosDavid DunhamView Answer on Stackoverflow
Solution 2 - IosRakesh iOS DevView Answer on Stackoverflow
Solution 3 - IosLucas P.View Answer on Stackoverflow
Solution 4 - IosXLE_22View Answer on Stackoverflow