Search code examples
accessibilityuiactivityindicatorviewvoiceover

Accessibility/Voice over Requirement on UIActivityIndicatorView


I am trying to provide an accessibility label for UIActivityIndicatorView (which is created programmatically in my view controllers viewDidLoad). I am setting the accessibility label as:

myIndicatorView.accessibilityLabel = @"Please wait, processing"

But when I run the application, the voice over always reads "in progress". I tried to debug on simulator using the accessibility inspector, but everytime the indicator view is in focus, it has the label as "in progress". I assume, "in progress" is default voice over text for activity indicators view, But I can not change this label. I am wondering if the activity indicator view's accessble label can never be changed. If somebody came across this issue and found a workaround, then please help me.


Solution

  • It's not that you're not changing it. It's that, in the background, as the status of the progress indicator changes, iOS backend updates the label, to the appropriate status. This is overriding whatever you changed it to, because it is likely applying its own update after you change the status.

    I would just leave this alone. "Please wait, processing" provides no additional information as compared to "In progress". And "In progress" is the way VoiceOver users will be accustomed to hearing an "In progress" state progress indicator announce. Changing this announcement is to a non-sighted user, what changing the image to a revolving Mickey Mouse head would be to sighted one.

    If you MUST change this, what you want to do, is instead of setting the property, override the implementation of the property's getter method. To do this provide a custom implementation of UIActivityIndicatorView that does the following.

    @interface MyActivityIndicator : UIActivityIndicatorView
    
    @end
    
    @implementation MYActivityIndicator
    
    - (NSString*)accessibilityLabel {
        if (self.isAnimating) {
            return NSLocalizedString("ACTIVITY_INDICATOR_ACTIVE", nil);
        } else {
            return NSLocalizedString("ACTIVITY_INDICATOR_INACTIVE", nil);
        }
    }