点击并按住以在 UIWebview 中保存图像
Tap and hold to save image in UIWebview
在我的应用程序中,我有一个显示图片列表的 UIWebView。现在,当有人用手指点击并按住图片时,就会出现复制该图片的选项。
有没有办法让它在有人点击并按住时出现保存该图片的选项?
欢迎任何想法!
您需要检测长按。为此,您需要添加:
@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];
并在应用检测到长按后要求用户保存图片。
- (void)handleLongPressGestures:(UILongPressGestureRecognizer *)sender
{
if ([sender isEqual:self.lpgr]) {
if (sender.state == UIGestureRecognizerStateBegan)
{
//prompt the user to save the picture .
}
}
}
在我的应用程序中,我有一个显示图片列表的 UIWebView。现在,当有人用手指点击并按住图片时,就会出现复制该图片的选项。
有没有办法让它在有人点击并按住时出现保存该图片的选项?
欢迎任何想法!
您需要检测长按。为此,您需要添加:
@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];
并在应用检测到长按后要求用户保存图片。
- (void)handleLongPressGestures:(UILongPressGestureRecognizer *)sender
{
if ([sender isEqual:self.lpgr]) {
if (sender.state == UIGestureRecognizerStateBegan)
{
//prompt the user to save the picture .
}
}
}