Custom UITableViewCell availability

As you can set the availability subviews UITableViewCells separately.
It should not be available as a complete cell?

+8
source share
3 answers

If your tableview cell consists only of text, it will make available to the cell, and it will read out the entire cell. If you have other objects and buttons, it is recommended to use a subclass of UITableViewCell and override the method -accessibilityElements to return all the available items.

Some code:

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

The next post can help:

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

+11
source

Make cell unavailable and your subrepresentations available in tableView(_:cellForRowAt:) .

 isAccessibilityElement = false mySubview1.isAccessibilityElement = true mySubview2.isAccessibilityElement = true mySubview3.isAccessibilityElement = true 

I also stuck in this, because I'm (trying to be effective) put the above in a custom method of init(style:reuseIdentifier:) . But it did not work, probably because UITableView resets everything after the initialization of each of its cells.

Related: Programming Guide for iOS Accessibility: improving accessibility tabular representations

+5
source

In response to @ ma11hew28, here's another way to keep some lines of code in Swift 5:

 class ServiceTableViewCell: UITableViewCell { override func awakeFromNib() { super.awakeFromNib() self.selectionStyle = .none self.isAccessibilityElement = false //not allowing accessibility for the cell itself self.accessibilityElements = [mySubview1!, mySubview2!, mySubview3!] // but allowing accessibility in the cell subviews } } the cell itself class ServiceTableViewCell: UITableViewCell { override func awakeFromNib() { super.awakeFromNib() self.selectionStyle = .none self.isAccessibilityElement = false //not allowing accessibility for the cell itself self.accessibilityElements = [mySubview1!, mySubview2!, mySubview3!] // but allowing accessibility in the cell subviews } } !] // but allowing accessibility in the cell subviews class ServiceTableViewCell: UITableViewCell { override func awakeFromNib() { super.awakeFromNib() self.selectionStyle = .none self.isAccessibilityElement = false //not allowing accessibility for the cell itself self.accessibilityElements = [mySubview1!, mySubview2!, mySubview3!] // but allowing accessibility in the cell subviews } } 
0
source

All Articles