Toggle Switch
If using more than one switch, make sure you give each a different number tag.
If you need to assign them to a sender function, for instance an event where value changed, assign all to the same function (same name). Delete all the additional events being created and change parameter type to UISwitch:
For instance, the following page has 6 switches:
If you need to assign them to a sender function, for instance an event where value changed, assign all to the same function (same name). Delete all the additional events being created and change parameter type to UISwitch:
For instance, the following page has 6 switches:
@IBAction func warmUpHasChanged(_ sender: UISwitch) {
print(sender.isOn)
if sender.isOn
{
switch(sender.tag)
{
case 1 : self.warmUpHasTimer = true
case 2: self.upperBodyHasTimer = true
case 3: self.coreHasTimer = true
case 4: self.lowerBodyHasTimer = true
case 5: self.danceHasTimer = true
default: self.coolDownHasTimer = true
}
}
else
{
switch(sender.tag)
{
case 1 : self.warmUpHasTimer = false
case 2: self.upperBodyHasTimer = false
case 3: self.coreHasTimer = false
case 4: self.lowerBodyHasTimer = false
case 5: self.danceHasTimer = false
default: self.coolDownHasTimer = false
}
}
}
Comments
Post a Comment