मेरे पास यूआईवीविच की एक जोड़ी वैल्यू चेंजेड इवेंट के माध्यम से आईबीएक्शन तक जुड़ी हुई है। जब स्विच छूए जाते हैं तो वैल्यू चेंजेड इवेंट फायरिंग ठीक होता है। हालांकि, अगर मैं प्रोग्राम में से एक स्विच को बदलता हूं तो यह मेरे आईबीएक्शन को कॉल नहीं करता है।यूआईएसविच वैल्यू चेंज इवेंट नहीं भेजता है जब प्रोग्रामेटिक रूप से बदलता है
- (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;
}
}
}