0

I have Updated my Xcode from version 10 to 11.

But now my App is not accepting any touch events or it is getting stuck while I turn the UISwitch. Then I removed all the connections from the UISwitch to check whether the mistake is from my code. But Still I am getting the same issue.

Does anybody have an idea to solve this issue? Thanks in advance.

Saranjith
  • 11,242
  • 5
  • 69
  • 122
Wide Angle Technology
  • 1,184
  • 1
  • 8
  • 28

1 Answers1

0

Alright I had the exact same problem on devices running iOS 13, and when I started running Xcode 11. The problem (for me at least) was that Apple (probably) made a bug fix for the issue with the "valueChanged" hook to a UISwitch, see:

Either way, what happened before was that the action for the switch got triggered twice, so I (apparently) set the switch to the right state myself. Like this:

@IBAction func notificationsSwitchTapped(_ sender: UISwitch) {
    if sender.isOn{
        sender.setOn(false, animated: true)
    }else{
        sender.setOn(true, animated: true)
    }
}

But as of iOS 13 Xcode 11, the "valueChanged" UISwitch bug got fixed and the .isOn() value I am checking, actually already is the new value:

@IBAction func notificationsSwitchTapped(_ sender: UISwitch) {
    if sender.isOn{
        // The switch has been turned on
    }else{
        // The switch has been turned off
    }
}

Long story short, your switch probably got called twice before so your Boolean of the UISwitch's state is the opposite for your Xcode 11 iOS 13 code.

Vasco
  • 837
  • 8
  • 9