The Swift
* Sample code - this Swift 3, but the key line of code to set the accessibilityElementsHidden is not specific to the Swift 3.
Before displaying cells (UITableViewCell) you should set the property accessibilityElementsHidden in true . This property indicates whether the accessibility elements contained in the accessibility element (in this case a cell) are hidden. accessibilityElementsHidden defaults false .
Inside init ()
The following code sets accessibilityElementsHidden true to initialize the user subclass UITableViewCell. This will work if the cell is created raskadroy, the nib or created software.
class CustomTableViewCell: UITableViewCell { override init(style: UITableViewCellStyle, reuseIdentifier: String?) { super.init(style: UITableViewCellStyle.default, reuseIdentifier: reuseIdentifier) self.accessibilityElementsHidden = true } required init?(coder aDecoder: NSCoder) { super.init(coder: aDecoder) self.accessibilityElementsHidden = true } } : String?) { class CustomTableViewCell: UITableViewCell { override init(style: UITableViewCellStyle, reuseIdentifier: String?) { super.init(style: UITableViewCellStyle.default, reuseIdentifier: reuseIdentifier) self.accessibilityElementsHidden = true } required init?(coder aDecoder: NSCoder) { super.init(coder: aDecoder) self.accessibilityElementsHidden = true } } reuseIdentifier) class CustomTableViewCell: UITableViewCell { override init(style: UITableViewCellStyle, reuseIdentifier: String?) { super.init(style: UITableViewCellStyle.default, reuseIdentifier: reuseIdentifier) self.accessibilityElementsHidden = true } required init?(coder aDecoder: NSCoder) { super.init(coder: aDecoder) self.accessibilityElementsHidden = true } }
Inside awakeFromNib ()
If CustomTableViewCell will be created only from the storyboard or nib, you can set the property in awakeFromNib() .
class CustomTableViewCell: UITableViewCell { override func awakeFromNib() { self.accessibilityElementsHidden = true } }
Inside tableView (_: cellForRowAt :)
If you created and overrides the cell programmatically, the code is as follows:
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { cellForRowAt indexPath: IndexPath) -> UITableViewCell { func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { cell func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
source share