wethu
1/26/2015 - 1:00 PM

someview.m

- (void)awakeFromNib {
    [super awakeFromNib];
    // tap and call boxTapped
    UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(boxTapped:)];
    tap.numberOfTapsRequired = 1;
    tap.cancelsTouchesInView = NO;
    // Some outlet views i wanna tap on
    NSArray *controls = @[self.brandNewBox, self.reprintBox, self.alterExistingBox, self.suppliedBox, self.alterSuppliedBox];
    // Assign tap gesture to all those views
    for (UIView *controlView in controls) {
        [controlView addGestureRecognizer:tap];
    }
}

- (void)boxTapped:(UITapGestureRecognizer *)sender {
    for (CPControlSwitch *aSwitch in sender.view.subviews) {
        if ([aSwitch isKindOfClass:[CPControlSwitch class]])
            [aSwitch setOn:!aSwitch.on animated:YES];
    }
}