我正在嘗試將手勢識別器添加到UIImageView,但是訪問不正確。在將UITapGestureRecognizer添加到UIImageView時出現Bad-Access
[UISwipeGestureRecognizer openPhotoDetail:]: unrecognized selector sent to instance 0x17e589a0
2014-09-02 12:01:32.569 FotoTR[1949:669649] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UISwipeGestureRecognizer openPhotoDetail:]: unrecognized selector sent to instance 0x17e589a0'
*** First throw call stack:
這是我的代碼;
mainView = [[UIScrollView alloc]initWithFrame:CGRectMake(0, 0, 320, 408)];
[self.view addSubview:mainView];
firstVerticalImageView = [[STGImageView alloc]initWithFrame:CGRectMake(4, 4, 153, 197)];
UITapGestureRecognizer *singleTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(openPhotoDetail:)];
[firstVerticalImageView addGestureRecognizer:singleTap];
[firstVerticalImageView setUserInteractionEnabled:YES];
[mainView addSubview:firstVerticalImageView];
[mainView bringSubviewToFront:firstVerticalImageView];
這是什麼問題?
我的openPhotoDetail方法;
-(void)openPhotoDetail:(id)sender
{
PhotoDetailViewController *photoDetailViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"photoDetailViewController"];
[self.navigationController pushViewController:photoDetailViewController animated:YES];
}
請發表您的openPhotoDetail:方法 – Rohan 2014-09-02 09:11:37
貴openPhotoDetail方法是在同級別比你UITapGestureRecognizer初始化? – streem 2014-09-02 09:31:31
openPhotoDetail方法在哪裏? – avismara 2014-09-02 11:13:42