【问题标题】:UIWebView, enable touch hold save image, like in mobile SafariUIWebView,启用触摸保存图像,就像在移动 Safari 中一样
【发布时间】:2012-10-06 10:19:15
【问题描述】:

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

感谢阅读!

【问题讨论】:

标签: iphone ios image uiwebview


【解决方案1】:
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.

【讨论】:

    【解决方案2】:

    您可以从创建 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
       }
     }
    

    【讨论】:

    • 谢谢!但是如何让 UIWebView 中按下的图片成为一个按钮呢?
    • 很棘手,就像您可以放置​​一个 webview Constome Button 然后您可以获得 UIButton 的事件... :)
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-01-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-04-23
    相关资源
    最近更新 更多