【发布时间】:2015-07-20 16:52:06
【问题描述】:
在我的应用程序中,我有一个显示图片列表的 UIWebView。现在,当有人点击并按住图片时,会出现复制该图片的选项。
有没有办法让它在有人点击并按住时出现保存该图片的选项?
欢迎任何想法!
【问题讨论】:
标签: objective-c image uiwebview
在我的应用程序中,我有一个显示图片列表的 UIWebView。现在,当有人点击并按住图片时,会出现复制该图片的选项。
有没有办法让它在有人点击并按住时出现保存该图片的选项?
欢迎任何想法!
【问题讨论】:
标签: objective-c image 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 .
}
}
}
【讨论】: