Skip to content

Instantly share code, notes, and snippets.

@wethu
Created January 26, 2015 13:00
Show Gist options
  • Select an option

  • Save wethu/229d6317dd5b059800c2 to your computer and use it in GitHub Desktop.

Select an option

Save wethu/229d6317dd5b059800c2 to your computer and use it in GitHub Desktop.
- (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];
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment