iOS Refresh Accessibility Label

ios accessibility
ios nested accessibility elements
accessibility label ios
accessibilityvalue vs accessibilitylabel
uitableviewcell accessibility
group accessibility elements ios

I have a button with accessibility label @"a". When the button is pressed, I have a callback that sets the accessibility label button.accessibilityLabel = @"b". I know this line of code runs. However, if I tap the button again, VoiceOver still reads a. Unfortunately, the code I'm working with is proprietary, so I can't share it directly.

However, in general, I would like to know what issues might cause VoiceOver to not recognize an update to a label.

THE BEST way to handle dynamic accessibility labels is to override the property functions on the views that are being focused (EX: on a UIButton). This allows TWO things. A: it's a lot easier to maintain than setting the property everywhere it can change. B: you can log information and see when the system is requesting that information, so you can better understand WHY things are happening. So even if it doesn't directly fix your issue, seeing WHEN the system requests your value, and logging that data, is inherently valuable.

Doing this in Objective C

@implementation YourUIButton

-(NSString*)accessibilityLabel {
    if(someCondition) {
        return @"a";
    } else {
        return @"b";


In Swift

public class YourUIButton : UIButton
    override public var accessibilityLabel: String? {
        get {
            if (someCondition) {
                return "a"
            } else {
                return "b"

        set {
            NSException.raise(NSException("AccessibilityLabelException", "You should not set this accessibility label.", blah))

You could also use this logic JUST to debug, and allow setting and such.

There are a lot of potential issues here. Race conditions, which view is actually getting focus, is there some parent child relationship going on, etc. Overriding the property and adding logging statements to the above code will help you understand what view is actually getting the accessibility label requested and when. Super valuable information!

iOS Refresh Accessibility Label, When the button is pressed, I have a callback that sets the accessibility label button.accessibilityLabel = @"b" . I know this line of code runs. However, if I tap the� iOS Refresh Accessibility Label. Ask Question Asked 2 years, 7 months ago. Active 5 months ago. Viewed 2k times 1. I have a button with accessibility

Try to add UIAccessibilityTraitUpdatesFrequently to your buttons property accessibilityTraits

- (void)viewDidLoad {
    myButton.accessibilityTraits |= UIAccessibilityTraitUpdatesFrequently

Also, when changing accessibilityLabel be sure that you're on main thread.

dispatch_async(dispatch_get_main_queue(), ^{
    myButton.accessibilityLabel = @"b";

accessibilityLabel, accessibilityLabel. A succinct label that identifies the accessibility element, in a localized string. Availability. iOS 3.0+; Mac Catalyst 13.0+; tvOS 9.0+. Framework. The label is a very short, localized string that identifies the accessibility element, but does not include the type of the control or view. For example, the label for a Save button is “Save,” not “Save button.” By default, standard UIKit controls and views have labels that derive from their titles.

Use this while changing button text .layoutChanged, argument: yourButton)

iOS Accessibility: Getting Started, accessibilityLabel. A string that succinctly identifies the accessibility element. Availability. iOS 3.0+; Mac� Figure 3 The Accessibility pane in the Identity Inspector. Add Accessibility Labels and Hints Programmatically . There are times when adding accessibility labels and hints in Xcode is not enough. For example, when you are working with custom UI elements which are not automatically recognized by VoiceOver or if you are using variables as part of

You don't really need a way to refresh the voice over labels. Its done automatically. I have tried this and it works as expected.

class ViewController: UIViewController {

    var tapCount = 0

    var button: UIButton!

    override func viewDidLoad() {
        // Do any additional setup after loading the view, typically from a nib.
        button = UIButton(type: .system)
        button.setTitle("Hello", for: .normal)
        button.frame = CGRect(x: 10, y: 10, width: 100, height: 50)

        button.accessibilityLabel = "Hello Button"
        button.accessibilityHint = "Tap here to start the action"
        button.accessibilityIdentifier = "hello_button"
        button.addTarget(self, action: #selector(buttonTap(sender:)), for: .touchUpInside)

    @IBAction func buttonTap(sender:UIButton) {
        tapCount = tapCount + 1
        sender.accessibilityLabel = "Hello button, tapped \(tapCount) times"

What Voice oversays:

Hello Button-pause-Button-pause-Tap here to start the action

On button tap

Hello button, tapped one times

Another tap

Hello button, tapped two times

Checklist: How to make your iOS app more accessible – Hacking , To fix these, you need to make the labels accessible and update their properties with a meaningful description. The accessibility element should cause an automatic page turn when VoiceOver finishes reading the text within it. static var header : UIAccessibility Traits The accessibility element is a header that divides content into sections, such as the title of a navigation bar.

Common Accessibility Element Pitfalls and How to Avoid Them, Make sure all elements have accessibility labels. These can be set in Interface Builder or by using the accessibilityLabel property. Your labels� The first is an accessibility setting of the same kind you can alternatively set directly with the k Sec Attr Accessible attribute, as described in the previous section. You don’t need to set the accessible attribute directly if you set it as part of the access control attribute instead.

UIAccessibility, You'll also understand why simply setting the accessibility element to NO isn't accessibility there are a few different properties iOS gives you access to. what traits the element has, or how detailed the label you've given it. iOS To enable VoiceOver, go to the Settings app on your iOS device (it's not available for simulator). Tap General, then Accessibility. There you will find many tools that people use to make their devices more usable, such as bolder text, increased contrast, and VoiceOver.

iOS developer guide, Accessibility, like internationalization, is one of those topics that's difficult to get Accessibility labels and hints tell VoiceOver what to say when Name}”, and the accessibilityValue to the content of that status update. Do yourself a favor and read the excellent Accessibility Programming Guide for iOS. The new accessibility documentation since iOS 8 is fantastic. Simplifying the complexity . Up until iOS 7, accessibility was basic: you attached labels and hints to things. Now it is very dynamic, interfaces are gestural. There is more support for custom behaviors and accessibility tools beyond VoiceOver (e.g. the Switch system).

  • Your question is not clear, try posting your code & what you tried
  • Your question is not clear
  • Any unclarity in what is being asked is due to ignorance of the reader. This is a fine question, with a valuable answer.
  • Thanks for the suggestion. I actually wasn't calling from the main thread. However, when I use the dispatch_async block as you suggested, VoiceOver still reads the old label. Any other ideas?
  • @kmell96, VoiceOver reads the label instantly after the tap (as you can see using Calculator app), try to set accessibilityLabel to nil right after a tap and in callback set it to @"b"
  • The reference to UIAccessibilityTraitUpdatesFrequently is misleading as to that traits purpose. The rest of this post is reasonable.
  • Topicstarter does the same, but VoiceOver don't catch an edit
  • Downvoters I need you valuable comments to improve this.
  • @GRiMe2D, how do you know topicstarter had done the same? I have pasted a simple snippet how this works, so this the OP does not miss anything essential. If the OP's case is different , we can alywas update the question as well as answer.