Last active
April 6, 2016 11:43
-
-
Save hulefei/31fabd15f1a5939b4dc64637318c9257 to your computer and use it in GitHub Desktop.
uiwebview 获取图片URL
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
UILongPressGestureRecognizer *gs = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(p_gestureRecognizerAction:)]; | |
gs.numberOfTouchesRequired = 1; | |
[self.view addGestureRecognizer:gs]; | |
- (void)p_gestureRecognizerAction:(UIGestureRecognizer *)gestureRecognizer { | |
if (gestureRecognizer.state == UIGestureRecognizerStateBegan) { | |
CGPoint touchPoint = [gestureRecognizer locationInView:gestureRecognizer.view]; | |
if(self.interfaceOrientation == UIInterfaceOrientationPortrait || self.interfaceOrientation == UIInterfaceOrientationPortraitUpsideDown) { | |
NSString *imgURL = [NSString stringWithFormat:@"document.elementFromPoint(%f, %f).src", touchPoint.x, touchPoint.y]; | |
_urlToSave = [self.webview stringByEvaluatingJavaScriptFromString:imgURL]; | |
NSLog(@"urlToSave :%@",_urlToSave); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment