iOS Voiceover status

后端 未结 4 1659
有刺的猬
有刺的猬 2021-02-01 00:10

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

相关标签:
4条回答
  • 2021-02-01 00:50

    In ViewDIdLoad

    [[NSNotificationCenter defaultCenter] addObserver:self
                                             selector:@selector(voiceOverStatusChanged)
                                                 name:UIAccessibilityVoiceOverStatusChanged
                                               object:nil];
    
    
    - (void)voiceOverStatusChanged
    {
        if(!UIAccessibilityIsVoiceOverRunning())
        {
            //do your changes
        }
    }
    
    0 讨论(0)
  • 2021-02-01 00:50

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

    UIAccessibility.isVoiceOverRunning

    0 讨论(0)
  • 2021-02-01 00:51
    BOOL UIAccessibilityIsVoiceOverRunning();
    
    0 讨论(0)
  • 2021-02-01 01:11

    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

    0 讨论(0)
提交回复
热议问题