How do i add an accessibility label to the minus image that gets added to the tableview cell?

1.2k views Asked by At

I am creating a tableView with custom cells, with each cell being created with the following code:

UITableViewCell    * cell = [tableView dequeueReusableCellWithIdentifier:kEditSymbolCellId];

I have returntableView.isEditing; set.

and i have the minus button visible from the get go. With the editing style set toUITableViewCellEditingStyleDelete
somewhere (if (editingStyle == UITableViewCellEditingStyleDelete) { passes).

Where would i have to change the code to add the accessibility label.

I am creating the cell of a custom class- the .h has only this in it:

@interface WidgetEditCell : UITableViewCell
@property (retain, nonatomic) IBOutlet UILabel *symbolLabel;
@property (retain, nonatomic) IBOutlet UILabel *subtitleLabel;

With ainitWithStyle and asetSelected in the .m nothing that changes the cursed minus image. someone please help.

1

There are 1 answers

1
App Dev Guy On BEST ANSWER

By default, there should be an accessibilityLabel built in that reads your label and places the message "delete" in front. I have tested a custom cell, see below:

testing accessibilityLabel

If that does not suit your needs, I have these suggestions:

  1. Add a UIAlertView to display a message when a person wishes to delete. This can have a voice message enabled, and, realistically is a pleasant way of going about business providing things aren't being deleted (my opinion).

  2. Create your own custom delete function following this tutorial from Ray Wenderlich. I have used it and find it really practical for customisability.

  3. I have not tried this, but create your accessibilityLabel whenever the edit option is used by creating a custom button, or UILabel that is set to Transparent.

    UIButton *someButton = [[UIButton alloc] initWithFrame:CGRectMake(x, y, h, w)];
    someButton.backgroundColor = [UIColor clearColor];
    someButton.accessibilityLabel = @"SomeNSString";
    

Have it fill the area around the button perhaps and then have it perform the delete function if that's called so it appears seem less. It's probably not the greatest option on the planet but I have yet to see another way.

Image from Ray Wenderlich

Image from Ray Wenderlich