How to use UISwipeGestureRecognizer on UIButton?
Posted
by
Ashutosh
on Stack Overflow
See other posts from Stack Overflow
or by Ashutosh
Published on 2012-03-28T17:04:00Z
Indexed on
2012/03/28
17:30 UTC
Read the original article
Hit count: 260
I have a UIbutton which i want to work as a joystick. So i am trying to add some gesture recognizer on the same button. I have this in my code right now:
UISwipeGestureRecognizer *recognizer;
recognizer = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(handleSwipeFrom:)];
[recognizer setDirection:(UISwipeGestureRecognizerDirectionUp)];
[self.gestureRecieverButton addGestureRecognizer:recognizer];
[recognizer release];
recognizer = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(handleSwipeFrom:)];
[recognizer setDirection:(UISwipeGestureRecognizerDirectionDown)];
[self.gestureRecieverButton addGestureRecognizer:recognizer];
[recognizer release];
-(void)handleSwipeFrom:(UISwipeGestureRecognizer *)recognizer {
NSLog(@"Swipe received.%@",recognizer);
}
This is the error i am getting now: -[CUETutorialSixteenClusterRootController handleSwipeFrom:]: unrecognized selector sent to instance 0x79b71b0 2012-03-28 13:25:55.724 CUETrainer[1788:11f03] * Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[CUETutorialSixteenClusterRootController handleSwipeFrom:]: unrecognized selector sent to instance 0x79b71b0'
But its not actually doing anything. Please help!!!!
© Stack Overflow or respective owner