问题
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?
Any ideas are welcomed!
回答1:
You need to detect the long tap. For that you need to add:
@property (nonatomic,strong) UILongPressGestureRecognizer *lpgr;
and in your view did load:
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 .
}
}
}
来源:https://stackoverflow.com/questions/31522037/tap-and-hold-to-save-image-in-uiwebview