Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

An extra UITableViewCellContentView overlay appears in a TableView on iOS 14 preventing taps, but works fine on iOS 13

On an iOS 14 device compiled with XCode 12 an extra UITableViewCellContentView is appearing above the content of the table view preventing any of the buttons underneath it from being tapped. This only appears in iOS 14. It does not appear in iOS 13. Any ideas on how to remove it? enter image description here

like image 465
Ravi Damani Avatar asked Sep 17 '20 06:09

Ravi Damani


3 Answers

You have to add your views to cell contentView like this:

contentView.addSubview(button)

and anchor your button to contentView:

button.topAnchor.constraint(equalTo: contentView.topAnchor).isActive = true
like image 84
tornic Avatar answered Oct 28 '22 21:10

tornic


If your project is big and it's hard to change every addSubview to contentView.addSubview, you can add this extension to your project:

extension UITableViewCell {
    open override func addSubview(_ view: UIView) {
        super.addSubview(view)
        sendSubviewToBack(contentView)
    }
}
like image 5
Ayan Kurmanbay Avatar answered Oct 28 '22 22:10

Ayan Kurmanbay


Had the same issue, we did this :

sendSubviewToBack(contentView)
like image 1
Guillaume Ramey Avatar answered Oct 28 '22 21:10

Guillaume Ramey