Search code examples
iosobjective-cuitableviewuibuttonvoiceover

VoiceOver reads UIButton in UITableViewCell as "dimmed"


I have added a UIButton to a UITableViewCell instead of the default UILabel. I did this so I can disable the button, and it's working great. I just set enabled to NO then also set userInteractionEnabled to NO for the cell. This works great for the sighted user because they can see the button is disabled (not tinted but grayed out), but for blind users VoiceOver is not distinguishing between enabled and disabled buttons. When I tap on the button that fills the area of the cell, no matter if the button is enabled or disabled, VoiceOver says "button_title, dimmed button." Dimmed is fine I think to tell users it's not interactive, but it shouldn't say it's dimmed when the button is enabled. Is this a bug I need to report to Apple, is there a problem with my setup, and how can I go about addressing this? Thanks!


Solution

  • To get the desired behavior, the UIButton should have user interaction disabled, then set its enabled state appropriately. Its accessibility options should be disabled with traits button and user interaction enabled checked. For the containing cell, it should have user interaction enabled as appropriate and its accessibility options should be enabled with traits button and user interaction enabled checked. Then when you want to enabled/disable the button, also enable/disable the cell's user interaction.

    With that setup, VoiceOver will say "button_title, dimmed, button" if disabled or will exclude dimmed if it is enabled.