我正在尝试将 aUILongPressGestureRecognizer
和 a添加UITapGestureRecognizer
到IBOutletCollection
of UIImageViews
,但它不起作用。这是我正在使用的代码:
UILongPressGestureRecognizer *pressRecognizer = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(deleteImage:)];
UITapGestureRecognizer *tapRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(selectImage:)];
pressRecognizer.delegate = self;
tapRecognizer.delegate = self;
for (UIImageView *imageView in myImageViewCollection)
{
[imageView addGestureRecognizer:pressRecognizer];
[imageView addGestureRecognizer:tapRecognizer];
imageView.userInteractionEnabled = YES;
}
- (void)selectImage:(UITapGestureRecognizer *)sender
{
NSLog(@"Select");
}
- (void)deleteImage:(UILongPressGestureRecognizer *)sender
{
NSLog(@"Delete");
}
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer
{
return YES;
}
我已经符合UIGestureRecognizerDelegate
. 我究竟做错了什么?