[英]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 .
}
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.