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
Querying in Firebase by Child of Child
Pod Install Gpuimage Does Not Work
Swift 4.2 - _Shared Attribute Near Type
Referencing Self in Super.Init
Expression Pattern of Type 'String' Cannot Match Values of Type 'Nsstoryboardsegue.Identifier
How to Pass a Nil Value for One of the Parameter in Alamofire Post Request
Lottieanimationview Size Won't Change/Is Too Small (Ios/Swift)
Charts Not Plotting in Tableviewcell
How to Customize the Font and Appearance of a Uialertcontroller in the New Xcode W/ iOS8
How to Declare Exponent/Power Operator with New Precedencegroup in Swift 3
How to Create a Circle with Rounded Ends for Each Quadrant
Images Inaccessible from Asset Catalog in a Swiftui Framework
Characters Is Unavailable' Please Use String Directly
Why Strings Are Not Equal in My Case
Swift - Encode and Decode a Dictionary [String:Any] into Plist
Delegate Must Respond to Locationmanager:Didupdatelocations Swift Eroor