点击并按住以在UIWebview中保存图像 [英] Tap and hold to save image in UIWebview

查看:131
本文介绍了点击并按住以在UIWebview中保存图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的应用程序中,我有一个显示图片列表的UIWebView。现在,当有人用手指敲击图片时,可以选择复制该图片。

In my app I have a UIWebView that shows a list of pictures. Right now, when someone taps and holds their finger on a picture, the option comes up to copy that picture.

有没有办法让人们点击并按住保存该图片的选项?

Is there a way to make it so that, when someone taps and holds, the option to save that picture appears?

欢迎任何想法!

推荐答案

你需要检测长龙头。为此你需要添加:

You need to detect the long tap. For that you need to add:

 @property (nonatomic,strong) UILongPressGestureRecognizer *lpgr;

并在您的视图中加载:

  self.lpgr = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(handleLongPressGestures:)];
self.lpgr.minimumPressDuration = 1.0f;
self.lpgr.allowableMovement = 100.0f;

[self.view addGestureRecognizer:self.lpgr];

并要求用户在应用检测到长按后保存图片。

and ask the user to save the picture once the app detects the long tap.

   - (void)handleLongPressGestures:(UILongPressGestureRecognizer *)sender
{
    if ([sender isEqual:self.lpgr]) {
        if (sender.state == UIGestureRecognizerStateBegan)
        {  
           //prompt the user to save the picture .
        }
    }
}

这篇关于点击并按住以在UIWebview中保存图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆