Accessibility Label for radio button on action?

Viewed 2289

In TableViewCell, I have custom imageview which act as a radio button. This imageview has two states

  1. Selected
  2. Not Selected

enter image description here

By default I have given, Accessibility label as "Selected Checkbox" and "checkbox". Now I want to speak voice text as "new item selected" when it selects and "item deselected" when deselected.

Can we give all four different label? How can I get the same.

Updated: I tried using

UIAccessibilityPostNotification(UIAccessibilityAnnouncementNotification,@"text")

but it skips the text which need to speak.

3 Answers

I'm not entirely sure what you are attempting to do here but I'll try to provide an alternative way of making this accessible.

Instead of treating each radio button as either selected or deselected would it not be better to treat the entire group of radio buttons as one combined accessibility element.

So if you have radio buttons for [cat, dog, rabbit, guinea pig]. Then your accessibility should read something like...

Animal selection group: none selected

or

Animal selection group: rabbit selected

etc...

Having said all of that... what is this UI you are trying to create?

Radio buttons are fundamentally not a part of iOS. It would be a much better alternative to use UI that users know. And then by doing this you make your accessibility issue a non-issue.

Perhaps a UIPickerView or a UITableView might be better alternatives to radio buttons?

Not sure what are you exactly want to do.

My assumption: You want to generate sound on click of a button for tableviewcell and also changing the image of Imageview at the same time while checking the state of it (selected or non-selected).

***** do it inside your customTableViewCell class...

  • create IBOutlets in .h or .m for your 3 items from customtableviewcell xib.
  • create boolean flag to maintain current state (selected or non selected) of that cell.

  • create IBaction selector(method) to get event(touch up inside) of button click. Inside this method write code which checks following.

BOOL selectState; //Make this Global in classfile

if(selectState) // selected state YES

{
        xyzImgView.image = //Your Non selection Image;
        selectState = !selectState;

        //Play your sound for Non selection

}
    else // selected state NO
    {
        xyzImgView.image = //Your selection Image;

        selectState = !selectState;

        //Play your sound for selection

    }

// Considering you have an IBOutlet to checkBoxButton

checkBoxButton.accessibilityLabel = checkBoxButton.isSelected ? "selected" : "not selected" checkBoxButton.accessibilityHint = checkBoxButton.isSelected ? "" : "Tap to select"

Related