10

I have UITableView in a test project that is created this way:

class ViewController: UIViewController, UITableViewDataSource, UITableViewDelegate {

    @IBOutlet weak var tableView: UITableView!

    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view, typically from a nib.
        tableView.delegate = self
        tableView.dataSource = self

    }

    // height?
    func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
        //return cellHeightWithoutSeparator + cellSeparatorHeight
        //print("YES!")
        return 80 // arbitrary
    }

    // table wants a UITableViewCell for each row
    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        let cell = tableView.dequeueReusableCell(withIdentifier: "Cell", for: indexPath) as! CustomCell
        // customize cell here
        return cell

    }

    // how many rows?
    func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return 50 // arbitrary
    }

}

The structure of the table view is:

enter image description here

So, as you can see the cell contains a button.

I want the button (or any clickable view that is a subview of the cell) to respond immediately to the touch-down event and so I unchecked "Delay Touch Down" in the ScrollView property inspector in the storyboard.

It is my understanding that unchecking that box is equivalent to the code:

tableView.delaysContentTouches = false

According to the docs, this method is supposed to work on IOS 2.0+

But setting this property true or false only works as expected on IOS 11 and 12, but on IOS 10 (and presumably earlier), it is as if the box was never unchecked and touches on the button are still delayed.

I understand that it is still possible to make views "clickable" in the cell, and respond immediately to "touch up inside," (because the touch-up event will cancel the delay on the touch-down), but I still want the touch down event to call immediately (on all iOS versions, not just 11+) because:

1) I want the re-order control to respond immediately.

2) I want to have visual feedback for touch-down be normal/immediate on views in the cell.

I have also consulted this similar, but not the same, question which was written 4 years ago, and I tried applying the answers, but none of those answers seem to apply to whatever the modern day reason for this problem is.

Does anyone know the cause and (preferably Swift) solution to this?

Chitra Khatri
  • 1,260
  • 2
  • 14
  • 31
Nerdy Bunz
  • 6,040
  • 10
  • 41
  • 100
  • It always helps alot to include a demo which has the problem :) – J. Doe Dec 26 '18 at 16:27
  • How exactly are you detecting the button tap? I just used an action on the touch up event and the response is instantaneous on iOS 9.3 and iOS 10, in the simulator. – m_katsifarakis Dec 31 '18 at 21:04
  • Right... When you unpress/lift, the "touch up" cancels the downdelay and still fires... but the *down* event was still delayed in the first place... compare the button's visual feedback ("down state highlighting" reponse) between <11 and 11+. Thanks though I just learned/clarified this now by re-testing. – Nerdy Bunz Jan 01 '19 at 00:15

0 Answers0