This seems to be a bit of a weird issue. I have a UIButton in an iterated tableViewCell
in a tableView
thats been placed in a regular ViewController
. For some reason, it only looks clicked (highlights from its default blue color to the lighter blue briefly and then back to the blue) on long press. It does whatever action I assign it (just started with a normal old print statement) on the regular click, but just doesn't look clicked. Anybody know how to fix this?
Button in its normal state:
Button after being clicked:
Button after being long pressed (sorry, had to take a picture with phone for this)
Edit: This is different from the answers in the iOS7 question because I am looking for an iOS 10 swift solution, not objective-c. Nor iOS7
This is normal behavior. It's due to UIScrollView's delaysContentTouches
property. Per Apple's docs:
If the value of this property is YES, the scroll view delays handling the touch-down gesture until it can determine if scrolling is the intent. If the value is NO , the scroll view immediately calls touchesShouldBegin:withEvent:inContentView:.
EDIT: This answer gives the the below solution. I've tested it and it does work. However, as it's doing casting magic, I wouldn't recommend you actually do this because it will inevitably break when Apple decides to change their view hierarchy behind-the-scenes.
tableView.delaysContentTouches = false
for case let x as UIScrollView in tableView.subviews {
x.delaysContentTouches = false
}
OLD ANSWER: This answer gives a solution, but it's really a hack and might cause your app to get rejected by Apple due to its use of private classes. Since the behavior is really a feature, I'd recommend you to leave it as it is.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With