5
valueChanged 이벤트를 통해 IBAction에 연결되는 UISwitches 쌍이 있습니다. 스위치를 터치하면 valueChanged 이벤트가 발생합니다. 그러나 스위치 중 하나를 프로그래밍 방식으로 변경하면 IBAction이 호출되지 않습니다.프로그래밍 방식으로 변경되면 UISwitch가 valueChanged 이벤트를 보내지 않음
- (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;
}
}
}