Problem with Gesture in Xcode 12 and iOS 14

Problem with gesture in Xcode 12 and iOS 14

I found the answer.

In iOS14 some reason, UITableViewCellContentView hierarchy is different.

In tableView(_:cellForRowAt:) I add subview

 cell.addSubview(contentScollView)

UITableViewCellContentView is blocking the gesture.

Change to

 cell.contentView.addSubview(contentScollView)

This solve my problem.

Problem with UITableView in XCode 12 and IOS 14

Update: Thank you all for your help.

I‘ve fixed it! It actually was a problem with the custom TableViewCell I don't know how I assumed that it was the general background of the TableView.(Thanks @Starsky for the hint with custom Cell - i guess you all know after hours of searching for minor bugs you can't come up with the simplest things hahaha). In the override init() function of the custom cell I called self.backgroundColor = .none which caused the bug after setting it to self.backgroundColor = .clear everything works as planed.

UIControl not recognizing tap inside table view cell, stopped working from iOS 14

Go to your TodoCell and add this in your initializer:

 override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {

super.init(style: style, reuseIdentifier: reuseIdentifier)
contentView.isUserInteractionEnabled = true

}

It will start working again. If you have not created the cells programatically then you can do this:

func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: todoCellIdentifier, for: indexPath) as! TodoCell

let todo = todoListViewModel.todos[indexPath.row]
cell.model = todo
cell.selectionStyle = .none
cell.contentView.isUserInteractionEnabled = true

let checkBox = cell.checkbox
checkBox.index = indexPath.row
checkBox.addTarget(self, action: #selector(onCheckBoxValueChange(_:)), for: .valueChanged) // touchUpInside also does not work.

return cell
}

To debug, you can print the value of contentView.isUserInteractionEnabled and it will give you the boolean and using that you can see if it is the issue or not. Most probably it will return false and the above solution works well for iOS 14 and Xcode 12.

GestureRecognizer not responding to tap

I discovered the answer after carefully combing through my code.

One of the parent views was created without supplying a frame:

While it's a noobish enough error to warrant deletion of this questions, odds are someone else will also have the same issue in the future...



Related Topics



Leave a reply



Submit