I have the following problem. I have a UIScrollView on which I have several buttons with icons set as images on these buttons. I have a long recognition button attached to each button. How can I show a smaller delete icon on the sender button with a long hard press? My goal is to create the behavior presented by iOS when a user wants to uninstall a specific application. This is the code for the buttons (with images):
//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];
This code is in a loop (see me in the code). My long click action is as follows:
- (void)longPressGestureRecognizerStateChanged:(UIGestureRecognizer *)gestureRecognizer { switch (gestureRecognizer.state) { case UIGestureRecognizerStateEnded: NSLog(@"Tapped!!!"); break; default: break; } }
How can I transfer the button that I clicked on this operation to show a smaller X-image in the upper right corner of the button?
source share