Hi there,
I´ve added a SwitchControl to a "SettingsCell". Since I've updated to iOS 14, the Switch is shown in the Settings but I can't switch it anymore. No action is possible.
Do someone know a solution for this issue?
I´ve added a SwitchControl to a "SettingsCell". Since I've updated to iOS 14, the Switch is shown in the Settings but I can't switch it anymore. No action is possible.
Code Block import Foundation import UIKit class SettingsCell: UITableViewCell { // MARK: - Properties var sectionType: sectionType? { didSet{ guard let sectionType = sectionType else { return } textLabel?.text = sectionType.description SwitchControl.isHidden = !sectionType.constrainsSwitch } } lazy var SwitchControl: UISwitch = { let SwitchControl = UISwitch() SwitchControl.isOn = true SwitchControl.isEnabled = true SwitchControl.onTintColor = UIColor(red: 55/255, green: 120/255, blue: 250/255, alpha: 1) SwitchControl.translatesAutoresizingMaskIntoConstraints = false SwitchControl.addTarget(self, action: #selector(handleSwitchAction), for: .valueChanged) return SwitchControl }() // MARK: - Init override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { super.init(style: style, reuseIdentifier: reuseIdentifier) addSubview(SwitchControl) SwitchControl.centerYAnchor.constraint(equalTo: centerYAnchor).isActive = true SwitchControl.rightAnchor.constraint(equalTo: rightAnchor, constant: -12).isActive = true } required init?(coder aDecoder: NSCoder) { fatalError("init(coder:) has not been implemented") } // Mark - selectors @objc func handleSwitchAction(sender: UISwitch){ if sender.isOn { print("Turned on") UIApplication.shared.registerForRemoteNotifications() } else{ UIApplication.shared.unregisterForRemoteNotifications() print("Turned off") } } }
Do someone know a solution for this issue?