Added UILongPressGestureRecognizer with handleLongPressOnPhotos action to ImageView file. The most related codes are as follows:
- (IBAction)handleLongPressOnPhotos:(UILongPressGestureRecognizer *)sender
{
self.imageWillBeSaved = (UIImageView *)sender.view;
UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:nil delegate:self cancelButtonTitle:@"Cancel" destructiveButtonTitle:@"Save the photo" otherButtonTitles: @"Go to the Original photo", nil];
actionSheet.actionSheetStyle = UIActionSheetStyleDefault;
[actionSheet showInView:self.view];
NSLog( @"actionSheet addr when created is %p", actionSheet );
[actionSheet release];
}
- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex
{
switch (buttonIndex) {
case 0:
UIImageWriteToSavedPhotosAlbum(self.imageWillBeSaved.image, self, @selector(image: didFinishSavingWithError:contextInfo:), nil);
break;
default:
break;
}
}
- (void)image:(UIImage *)image didFinishSavingWithError:(NSError *)error contextInfo:(void *)contextInfo
{
if (error != NULL)
{
}
else
{
}
}
The action sheet will not be rejected after clicking the "save photo" button. If I press the button again, the action sheet will be rejected and the photo will be saved twice. Any problem in the code? Thanks in advance!
Ps. imageView is the subtitle of scrollView, and scrollView is in the ViewCell table .
- (IBAction)handleLongPressOnPhotos:(UILongPressGestureRecognizer *)sender
{
self.imageWillBeSaved = (UIImageView *)sender.view;
UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:nil delegate:self cancelButtonTitle:@"Cancel" destructiveButtonTitle:@"Save the photo" otherButtonTitles: @"Go to the Original photo", nil];
actionSheet.actionSheetStyle = UIActionSheetStyleDefault;
[actionSheet showInView:self.view];
NSLog( @"actionSheet addr when created is %p", actionSheet );
[actionSheet release];
}
handleLongPressOnPhotos: breakPoint1 breakPoint1. , imageView longPressed. : breakPoint1 → breakPoint2 → breakPoint1 → breakPoint2 → breakPoint3 → breakPoint4 → breakPoint3 → breakPoint4, . , ActionSheet , . , .
UILongPressGestureRecognizer
@Laddu, @MichaelDautermann, @sreecharan