Custom UITableViewCell accessibility

前端 未结 4 1920
别那么骄傲
别那么骄傲 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:43

    Contibuting to answer of @ma11hew28, here is another way to do that saves 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's subviews
        }
    }
    

提交回复
热议问题