I am currently trying to make a signout button for an app.
I have the UIImageView
"User Interaction Enabled" box checked.
in my .h
file I have this:
@property (strong, nonatomic) IBOutlet UIImageView *signOutButtonIV;
in my .m file I have this:
- (void) viewDidLoad{
[super viewDidLoad];
UITapGestureRecognizer* tapGestureRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapResponder:)];
tapGestureRecognizer.numberOfTapsRequired = 1;
tapGestureRecognizer.numberOfTouchesRequired = 1;
[self.signOutButtonIV addGestureRecognizer:tapGestureRecognizer];
}
-(void) tapResponder:(UITapGestureRecognizer *) sender{
NSLog(@"single tap detected");
}
If I instead use [self addGestureRecognizer:tapGestureRecognizer]
the taps will be detected. Is there a step I am missing?
Can also use storyboard to achieve the results:-