I abstracted this out so that you can see that it will work. The problem is something in your selector it has nothing to do with the UITapGestureRecognizer
UITapGestureRecognizer *tapRecog = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(weeee)];
tapRecog.numberOfTapsRequired = 2;
[self.view addGestureRecognizer:tapRecog];
- (void)weeee
{
NSLog(@"Two taps");
self.wee = !self.wee;
if (!self.wee) {
self.view.backgroundColor = [UIColor redColor];
NSLog(@"Wee is false");
} else {
self.view.backgroundColor = [UIColor whiteColor];
NSLog(@"Wee is true");
}
}
If you add that to a project (include a BOOL
property for wee
and set it in viewDidLoad
) every time you double tap the background color will change.
With regards to your code I would recommend setting some break points and figuring out what values are set and what they're set to. Somewhere, there is something thats not happening the way you're expecting it to happen. For example if isTorchActive
is never true, then it'll always switch to white. I don't know where you're setting that, but that is most likely the problem.