当用户在我的应用中的UIWebView中触摸图像时,我想启用保存图像和复制。是否有一个属性可以启用此功能,还是需要编写一些特殊方法来实现此目的?
感谢阅读!
答案 0 :(得分:2)
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.
答案 1 :(得分:0)
您可以通过创建UILongPressGestureRecognizer实例并将其附加到按钮来开始。
UILongPressGestureRecognizer *longPress = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(longPress:)];
[self.button addGestureRecognizer:longPress];
[longPress release];
然后实现处理手势的方法
- (void)longPress:(UILongPressGestureRecognizer*)gesture {
if ( gesture.state == UIGestureRecognizerStateEnded ) {
NSLog(@"Long Press");
//do something
}
}