1、添加手势识别:
`UITapGestureRecognizer*tap= [[UITapGestureRecognizeralloc]initWithTarget:selection:@selector(imgTapClick:)];`
`UILongPressGestureRecognizer*longTap =[[UILongPressGestureRecognizeralloc]initWithTarget:selection:@selector(imglongTapClick)];`
2、 imglongTapClick:
-(void)imglongTapClick:(UILongPressGestureRecognizer*)gesture { if(gesture.state ==UIGestureRecognizerStateBegan) { UIActionSheet *actionSheet = [[UIActionSheetalloc]initWithTitle:@"保存图片" delegate:self cancelButtonTitle:@"取消" destructiveButtonTitle:nil otherButtonTitles:@"保存图片到手机",nil];
actionSheet.actionSheetStyle = UIActionSheetStyleBlackOpaque; [actionSheetshowInView:self]; UIImageView *img = (UIImageView*)[gestureview] _sentImg = img } } -(void)actionSheet:(UIActionSheet*)actionSheet didDismissWithButtonIndex:(NSInteger)buttonIndex { if(buttonIndex ==0) { UIImageWriteToSavedPhotosAlbum(_sentImg.image,self,@selector(imageSavedToPhot osAlbum:didFinidhSavingWithError:contextInfo:),nil) } }
pragma mark --- UIActionSheetDelegate---
-(void)imageSavedToPhotosAlbum:(UIImage*)image didFinishSavingWithError:(NSError*) contextInfo:(void*)contextInfo { NSString *message = @"呵呵"; if(!error) { message = @"成功保存到相册"; UIAlertView *alert = [[UIAlertViewalloc]initWithTitle:@"提示" message:messagedelagate:selfcancelButtonTitle:@"确定" otherButtonTitles:nil]; [alert show] } else { message = [error description]; UIAlertView *alert = [[UIAlertViewalloc]initWithTitle:@"提 示" message delegate:selfcancelButtonTitle:@"确定"otherButtonTitles:nil]; [alert show]; } }