I have an from UIViewController derived Class named AdminViewController.
I want to enable singleTab Recognizer to this View.
The View is Called in an the MainViewController with:
AdminViewController* AdminViewC = [[AdminViewController alloc]init];
[self.view addSubview:AdminViewC.view];
In the AdminViewController.m
- (BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer{
if([gestureRecognizer isKindOfClass:[UITapGestureRecognizer class]])
{
[gestureRecognizer addTarget:self action:@selector(tappedGestureAction:)];
}
return YES;
}
-(void)tappedGestureAction:(UITapGestureRecognizer *)tap{
UIAlertView *av = [[UIAlertView alloc] initWithTitle:@"View Tapped" message:@"Tapped" delegate:nil cancelButtonTitle:@"Dissmiss" otherButtonTitles:@"Done", nil];
[av show];
}
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view from its nib.
[self.view setFrame:CGRectMake(500, -200, 200, 300)];
UITapGestureRecognizer *singleFingerTap =
[[UITapGestureRecognizer alloc] initWithTarget:self.view action:@selector(handleSingleTap:)];
[self.view addGestureRecognizer:singleFingerTap];
}
If i Touch the View in my MainViewController i get this:
‘NSInvalidArgumentException’, reason: ‘-[UIView handleSingleTap:]: unrecognized selector sent to instance 0x296d50’
has someone a hint?
regards, phil
You have added your gesture on
self.view, but you did not implement single tap selector: