What can UITableViewCell detect only multitouch? If I touch with one finger, it does not 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) } }
ios uitableview swift didselectrowatindexpath
Juicyfruit
source share