Custom UITableViewCell accessibility

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

    Make the cell inaccessible and your subviews accessible in tableView(_:cellForRowAt:).

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

    I got stuck on this too because I (trying to be efficient) put the above in my custom cell's init(style:reuseIdentifier:) method. But, that didn't work, probably because UITableView resets everything after initializing each of its cells.

    Related: Accessibility Programming Guide for iOS: Enhance the Accessibility of Table Views

提交回复
热议问题