Availability Shortcut for switch to action?

In TableViewCell , I have a custom image that acts like a switch. This image has two states.

  • Selecteded
  • Not chosen

enter image description here

By default, I provided the Accessibility label as "Selected Checkbox" and "checkbox". Now I want to speak the voice text as “new item selected” when it selects, and “item canceled” when deselecting.

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

Updated: I tried using

 UIAccessibilityPostNotification(UIAccessibilityAnnouncementNotification,@"text") 

but he misses the text to be spoken.

+5
source share
2 answers

I'm not quite sure what you are trying to do here, but I will try to provide an alternative way to make this available.

Instead of considering each switch as selected or deselected, it would not be better to consider the entire group of switches as one combined accessibility element.

So, if you have switches 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 this ... what kind of user interface are you trying to create?

Radio buttons are fundamentally not part of iOS. It would be much better to use a user interface that users know. And then by doing this, you make the accessibility problem a problem without problems.

Perhaps a UIPickerView or UITableView might be better alternatives to switches?

+5
source

Not sure what exactly you want to do.

My guess: you want to generate sound by pressing a button for a tableviewcell, and also change the Imageview image, checking its status (selected or not selected).

***** do this inside your customTableViewCell class ...

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

  • create an IBaction selector (method) to get the event (touch inside) of a button click. Inside this method, write code that checks the 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 } 
0
source

Source: https://habr.com/ru/post/1273312/


All Articles