Show delete button while rocking image and delete this image

I added scroll images. With long-term printing, I gave an animation wobble for all the images. I want to show the delete button in the upper right corner of each image, as in the iphone, when we remove any application the same as this.

- (void)startWobble { for (UIView *imgView in viewsInScrollView) { UIButton *deleteImgButton = [[UIButton alloc] initWithFrame:CGRectMake(55,-7,12,12)]; [deleteImgButton setImage:[UIImage imageNamed:@"close_icon.png"] forState:UIControlStateNormal]; [deleteImgButton addTarget:self action:@selector(deleteImage:) forControlEvents:UIControlEventTouchUpInside]; [imgView addSubview:deleteImgButton]; imgView.transform = CGAffineTransformRotate(CGAffineTransformIdentity, RADIANS(-5)); [UIView animateWithDuration:0.20 delay:0.0 options:(UIViewAnimationOptionAllowUserInteraction | UIViewAnimationOptionRepeat | UIViewAnimationOptionAutoreverse) animations:^ { imgView.transform = CGAffineTransformRotate(CGAffineTransformIdentity, RADIANS(5)); } completion:NULL ]; } } -(void)deleteImage : (id)sender { NSLog(@"Delete Image"); } 

here the selector is not called .... how can I solve this .. ???

+4
source share
3 answers

You can first add a delete button with a TAG value in all your custom views and hide them. Now in the - (void)startWobble you can just show them only using their TAG.

I did this in one of my applications this way. Hope this helps you.

+1
source

Plain.....

 #define RADIANS(degrees) ((degrees * M_PI) / 180.0) CGAffineTransform leftWobble = CGAffineTransformRotate(CGAffineTransformIdentity, RADIANS(-5.0)); CGAffineTransform rightWobble = CGAffineTransformRotate(CGAffineTransformIdentity, RADIANS(5.0)); itemView.transform = leftWobble; // starting point [UIView beginAnimations:@"wobble" context:itemView]; [UIView setAnimationRepeatAutoreverses:YES]; // important [UIView setAnimationRepeatCount:10]; [UIView setAnimationDuration:0.25]; [UIView setAnimationDelegate:self]; [UIView setAnimationDidStopSelector:@selector(wobbleEnded:finished:context:)]; itemView.transform = rightWobble; // end here & auto-reverse [UIView commitAnimations]; ... - (void) wobbleEnded:(NSString *)animationID finished:(NSNumber *)finished context:(void *)context { if ([finished boolValue]) { UIView* item = (UIView *)context; item.transform = CGAffineTransformIdentity; } } 

Got it from thisQuestion

+1
source

Found this quote from apple docs and remembered your question:

During animation, user interactions are temporarily disabled for animated views. (Prior to iOS 5, user interactions were disabled for the entire application.)

0
source

All Articles