2012-10-16 40 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. 
相關問題