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); } } }
webview点击获取图片
猜你喜欢
转载自hulefei29.iteye.com/blog/2288069
今日推荐
周排行