Custom UITableViewCell accessibility

前端 未结 4 1908
别那么骄傲
别那么骄傲 2021-02-13 23:09

How can you set the accessibility of subviews of UITableViewCells individually.
It should not be accessible as complete cell?

4条回答
  •  北海茫月
    2021-02-13 23:53

    If your tableview cell consists of text only, enabling accessibility for the cell will do and it will read out the whole cell. If you have other objects and buttons, it is recommended to use a subclass of UITableViewCell and override the -accessibilityElements method to return all your accessible elements.

    Some code:

    #import "CustomCell.h"
    
    @implementation CustomCell
    
    - (void)awakeFromNib
    {
        [super awakeFromNib];
        self.accessibilityElements = @[self.view1, self.label, self.imageView];
    }
    

    Following post may help:

    http://cocoacaffeine.wordpress.com/2013/11/29/little-tricks-of-accessibility/

提交回复
热议问题