0
我有一個來自UIViewController派生類的名爲AdminViewController的類。點擊UIView上的手勢作爲子視圖獲取BAD ACCESS
我想爲此視圖啓用singleTab識別器。
的看法是在叫MainViewController有:
AdminViewController* AdminViewC = [[AdminViewController alloc]init];
[self.view addSubview:AdminViewC.view];
在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];
}
如果我摸着我的MainViewController查看我得到這個:
'NSInvalidArgumentException',原因:' - [UIView handleSingleTap:]:無法識別的選擇器發送到實例0x296d50'
有人提示嗎? 問候,菲爾