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

Viewed 2790

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

7 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

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)
    }
}

I had this same issue, although I'm not sure my solution will work for you or not. My issue was caused by the UISearchControllerDelegate method presentSearchController being called twice in iOS14. When this method was called, we superimposed a new "containerView" onto our current View and displayed our search results. when didDismissSearchController is called we removed this view. The problem is that presentSearchController was being called twice, which created two "containerViews". we would remove one of them but the other one stuck around and intercepted all of our touches. We just needed to make sure not to add two "containerViews".

Here is what we did

func presentSearchController(_ searchController: UISearchController) { 

   guard containerView == nil else {return}

   containerView = UIView()
   viewController.view.addSubview(containerView)

   //present search results

}

func didDismissSearchController(_ searchController: UISearchController) { 

   containerView.removeFromSuperview()
   containerView = nil

   //any other code you need

}

Had the same issue, we did this :

sendSubviewToBack(contentView)

I have faced this issue recently in iOS 14.5. May my fix helps to save others time.

Just enable clips to bounds for your cell in attribute manager or programmatically make this bool true. Now cell bottom extra view is not overlaid and appears.

you should set the tableview separator style to none. in my case, any other answers didn't work. Just set the separator style to none, then UITableViewCellContentView will be removed.

Try this code

contentView.isUserInteractionEnabled = true
Related