我有以下问题。我有一个UIScrollView,在上面有几个带图标的按钮。每个按钮都附有长按识别器。如何在长按手势上向发送者按钮显示较小的删除图标?我的目标是创建iOS在用户想要删除特定应用程序时呈现的行为。
这是带有图片的按钮的代码:
//set the button with the image of conference here.
UIButton * button = [UIButton buttonWithType:UIButtonTypeCustom];
button.frame = CGRectMake(3, 3, w-5, h-5);
CALayer * l = [button layer];
[l setMasksToBounds:YES];
[l setCornerRadius:8.0];
[button setImage:thumb forState:UIControlStateNormal];
button.property = confInfo;
[button addTarget:self action:@selector(buttonClicked:) forControlEvents:UIControlEventTouchUpInside];
button.tag = i;
bView.tag = i;
//Add gesture recognizer to be used for deletion of conference.
UILongPressGestureRecognizer *pahGestureRecognizer = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(longPressGestureRecognizerStateChanged:)];
pahGestureRecognizer.minimumPressDuration = 1.0;
[button addGestureRecognizer:pahGestureRecognizer];
这段代码在一个循环中(请看代码中的i)。我的长按操作如下:
- (void)longPressGestureRecognizerStateChanged:(UIGestureRecognizer *)gestureRecognizer {
switch (gestureRecognizer.state) {
case UIGestureRecognizerStateEnded:
NSLog(@"Tapped!!!");
break;
default:
break;
}
}
我怎样才能将我点击的按钮传递给这个动作,以便在按钮右上角显示较小的X图片?