ios


didSelectRowAt called only on multitouch


What can make UITableViewCell detect only multitouch? If I tap with one finger it doesn't call didSelectRowAtIndex.
Here is my Code:
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "bookingSettingsCell", for: indexPath) as! SettingsTableViewCell
if indexPath.row < 3 {
cell.settingSwitch.removeFromSuperview()
}
cell.settingTitle.text = dataForSetting[indexPath.row].first
if dataForSetting[indexPath.row].last != "Pencil" {
cell.settingValue.isHidden = true
cell.settingChangable.isHidden = true
cell.settingSwitch.isHidden = false
}
return cell
}
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
DispatchQueue.main.async(execute: {
if indexPath.row < 3 {
let destinationVC = self.storyboard?.instantiateViewController(withIdentifier: "DatePicker") as! DatePickerViewController
destinationVC.modalPresentationStyle = .overCurrentContext
destinationVC.delegate = self
self.present(destinationVC, animated: true, completion: nil)
}
})
}
UITableViewCell class:
class SettingsTableViewCell: UITableViewCell {
#IBOutlet var settingTitle: UILabel!
#IBOutlet var settingChangable: UIImageView!
#IBOutlet var settingValue: UILabel!
#IBOutlet var settingSwitch: UISwitch!
override func awakeFromNib() {
super.awakeFromNib()
settingSwitch.transform = CGAffineTransform(scaleX: 0.65, y: 0.60)
}
}
You can handle the behavior of uitableviews's didSelectRowAt method after implementing the delegate methods of gesture recognizer. This prevents the undefined behavior of taps between uiview and tableViewCell and keeps the record of touches.
UIGestureRecognizerDelegate method:
func gestureRecognizer(gestureRecognizer: UIGestureRecognizer, shouldReceiveTouch touch: UITouch) -> Bool {
println("in shouldReceiveTouch")
gestureRecognizer.delegate = self
if (touch.view == tableView){
println("touching tableView list")
return false
}
else{
println("touching elsewhere")
return true
}
}
I think that the problem isn't in didSelectRowAt but in a UITableViewCell...
are you using the constraint logic when you design the xib?
Is possible that some object (label or imageView) create problem with touch...
review your constraint or design your tableViewCell direct in uitableView from storyboard.
I figured out that this happened because I added UITapGestureRecognizerto my superview so I can hide keyboard on touch. But actually still don't understand why in this case it worked with multitouch? I would suggest that my mistake should block all tap events.
You can solve this problem by adding the UIGesture recogniser delegate in your class. Add the UIGestureRecognizerDelegate in your class. Follow these steps:-
/*
class SignupInstructorViewController: UIViewController, UIGestureRecognizerDelegate
Note:- Now for identify whether you are tapping on tableView or some where else you have to implement this gesture delegate like this.
//MARK:- Gesture delegates
func gestureRecognizer(gestureRecognizer: UIGestureRecognizer, shouldReceiveTouch touch: UITouch) -> Bool {
// if user touch the tableview then below condition will be true
if touch.view != nil && (touch.view!.isDescendantOfView(tableViewName)) {
return false
}
return true
}
HopeFully, it will works for you.
Thanks in Advance.
*/

Related Links

Unable to set top margin NSLayout Constraint programatically in iOS?
iOS Universal link not working
Call a function of an another class (protocol)
Objective C ternary operator vs if statements nil check
Login error in iOS 9 Facebook SDK
How to map each Pixel to Vertex effectively with OpenGL ES on iOS?
how can i make a pop up menu in sprite kit swift? [closed]
Spritekit - Increase duration every 10 points
Allowing user to input nil values with Swift optionals
iOS Developer and Distribution certificate expiring while app in Test Flight
change color uipagecontroller
Magento API with iOS application and Oauth 1.0 Login
How to insure non logged inuser data submitted to parse.com only comes from mobile app
Passing 'self' issue in ios swift
Change style of table with Eureka Framework
AppDelegate declaration in a second view

Categories

HOME
asana
amazon-kinesis
oracle-adf
build.gradle
r-caret
wget
ceph
autofac
square-connect
uwsgi
development-environment
command-line-interface
oracle-agile-plm
graph-tool
postgresql-9.5
export-to-excel
syswow64
round-robin
aerospike
gas
abaqus
pydev
spark-graphx
datamatrix
hough-transform
zos
sax
epicorerp
iar
android-security
flexjs
meanjs
silverlight-5.0
magento2.0.2
cloudinary
ose
tensor
querydsl
sieve-of-eratosthenes
spring-data-cassandra
p4-lang
zipline
jetty-9
sagepay
dsx
pac
using
spark-submit
clientscript
ssms-2012
domdocument
jasmine2.0
simple.odata.client
maven-versions-plugin
typesetting
flying-saucer
android-alertdialog
mit-scheme
cufft
submission
nuitka
bash-completion
groupbox
membership
genetic
par
wt
avalonedit
bonfire
data-science-studio
fortrabbit
vraptor
scribe
words
nolio
tortoisecvs
gnat
symfony-2.5
citymaps
epoll
bessel-functions
asf
before-save
linguistics
tinkerpop-frames
css3pie
validform
scala-pickling
apache-commons-dbcp
hresult
xcode4.2
src
tempo
dynamic-usercontrols
gigaspaces
clean-urls
guvnor
android-actionbar-compat
nextpeer
vim-fugitive
ria
mknetworkkit
httpcontext.cache
b-method
ramaze
plinqo
coolstorage
syncml
mkmapviewdelegate
unitils
keylogger
n900
posterous
xlink

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App