Voici la méthode IBAction liée à la UISwitch avec l'événement valueChanged:UISwitch ne pas retourner son état actuel (on/off)
- (IBAction) sanitySwitch {
if (checkoption.on == YES) {
NSLog(@"SanityCheck ENABLED");
sanityCheck = YES;
} else {
NSLog(@"SanityCheck DISABLED");
sanityCheck = NO;
}
}
Il retourne toujours "SanityCheck HANDICAPÉS". L'option de contrôle UISwitch est correctement liée à son objet à partir du fichier XIB et les paramètres @propery et @syntetize appropriés ont été placés.
Pour baliser code indent par 4 espaces ou sélectionnez le code et appuyez sur le bouton '010' - pas besoin de tag html etc. –
+1 et merci beaucoup ... :) – Sarah
J'ai eu un problème totalement étrange où vous avez POUR UTILISER "expéditeur", plutôt que self.yourSwitch, pour que "isOn" (ou .on) fonctionne. Qui sait? – Fattie