我有一对通过ValueChanged事件挂接到一个IBAction为UISwitches的。 当开关被触动ValueChanged事件被解雇的罚款。 然而,开关的,如果我改变一个编程它不叫我的IBAction为。
- (IBAction)switchChanged:(UISwitch *)sender {
if (sender == self.shippingSwitch) {
if (self.shippingSwitch.on && !self.PayPalSwitch.on) {
[self.PayPalSwitch setOn:YES animated:YES];
}
}
if (sender == self.PayPalSwitch) {
if (!self.PayPalSwitch.on) {
// This is not working when the PayPal switch is set via the code above
self.PayPalEmailField.backgroundColor = [UIColor grayColor];
self.PayPalEmailField.enabled = NO;
if (self.shippingSwitch.on) {
[self.shippingSwitch setOn:NO animated:YES];
}
} else {
self.PayPalEmailField.backgroundColor = [UIColor clearColor];
self.PayPalEmailField.enabled = YES;
}
}
}