Availability / Voice Requirement for UIActivityIndicatorView

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

myIndicatorView.accessibilityLabel = @"Please wait, processing" 

But when I launch the application, the voice is always read "in progress". I tried to debug the simulator using the availability inspector, but every time the presentation of the indicator is in focus, it has a label as "in progress". I assume that "in progress" is the standard voice text for displaying activity indicators, but I cannot change this shortcut. I am wondering if it is possible to change the access label to the activity indicator. If someone came across this problem and found a workaround, please help me.

+5
source share
2 answers

Not that you do not change it. This means that in the background, when the status of the progress indicator changes, the iOS database updates the label to the corresponding state. This overrides everything you changed it to, because most likely you are using your update after changing the status.

I would just leave it alone. "Wait Processing" does not provide additional information compared to "In progress". And "In progress" is how VoiceOver users will be used to hearing the "In progress" progress indicator. Changing this ad for an unsuspected user is that changing the image to a Mickey Mouse rotating head would be aimed.

If you MUST change this, then what you want to do, instead of setting the property, is to override the implementation of the getter method of the property. To do this, create a custom implementation of UIActivityIndicatorView, which 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); } } 
+5
source

UIActivityIndicatorView subclass in Swift

The implementation of the accessibilityLabel getter in the UIActivityIndicatorView is dynamic based on the state of the control. Therefore, if you set its accessibilityLabel , it may change later.

The following subclass of UIActivityIndicatorView overrides the standard accessibilityLabel implementation. It is based on @ChrisCM's answer in Objective C.

 class MyActivityIndicatorView: UIActivityIndicatorView { override var accessibilityLabel: String? { get { if isAnimating { return NSLocalizedString("ACTIVITY_INDICATOR_ACTIVE", comment: ""); } else { return NSLocalizedString("ACTIVITY_INDICATOR_INACTIVE", comment: ""); } } set { super.accessibilityLabel = newValue } } } 

In my application, the activity indicator is displayed on the screen, and VoiceOver - only during animation. Therefore, I need only one accessibilityLabel value. The following subclass uses the default dynamic implementation of the default accessibilityLabel , unless explicitly specified. If set, it uses this value regardless of state.

 class MyActivityIndicatorView: UIActivityIndicatorView { private var accessibilityLabelOverride: String? override var accessibilityLabel: String? { get { if accessibilityLabelOverride != nil { return accessibilityLabelOverride } return super.accessibilityLabel } set { accessibilityLabelOverride = newValue } } } // Example use let activityIndicatorView = MyActivityIndicatorView(activityIndicatorStyle: .gray) activityIndicatorView.accessibilityLabel = NSLocalizedString("ACTIVITY_INDICATOR", comment: "") 
0
source

All Articles