Reputation: 5132
I'd like to enable Save Image and Copy when a user touch-holds an image in a UIWebView in my app. Is there a property that will enable this or will I need to write some special methods to accomplish this?
Thanks for reading!
Upvotes: 1
Views: 2871
Reputation: 2163
UIImage * downloadImage = [[UIImage alloc] initWithContentsOfFile:path];
UIImageWriteToSavedPhotosAlbum(downloadImage,nil, nil, nil);
[downloadImage release];
UIAlertView * alert = [[UIAlertView alloc] initWithTitle:@"Saved" message:@"Wallpaper saved to your Gallery." delegate:nil cancelButtonTitle:@"Dismiss" otherButtonTitles:nil, nil];
[alert show];
[alert release];
Add this whole code to your long press method, it will save your image in gallery.
Upvotes: 2
Reputation: 49730
You can start off by creating and attaching the UILongPressGestureRecognizer instance to the button.
UILongPressGestureRecognizer *longPress = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(longPress:)];
[self.button addGestureRecognizer:longPress];
[longPress release];
And then implement the method that handles the gesture
- (void)longPress:(UILongPressGestureRecognizer*)gesture {
if ( gesture.state == UIGestureRecognizerStateEnded ) {
NSLog(@"Long Press");
//do something
}
}
Upvotes: 0