2012-10-16 42 views
1

我想启用保存图像和复制,当用户在我的应用程序中的UIWebView中保持图像。有没有一个属性可以实现这一点,或者我是否需要编写一些特殊的方法来实现这一点?UIWebView,启用触摸保存图像,如在移动Safari中

感谢您的阅读!

+0

检查此链接http://iky1e.tumblr.com/post/5109242276/tutorial-customise-uiwebview-menu – prasad

回答

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 
    } 
} 
+0

谢谢!但如何使图像在UIWebView中按下一个按钮? – Mrwolfy

+0

就像你可以把一个webview Constome Button那么棘手,然后你可以得到UIButton的事件... :) –

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. 
相关问题