Created
July 10, 2012 05:31
-
-
Save doskoi/3081328 to your computer and use it in GitHub Desktop.
Getting image from UIWebView
This file contains hidden or 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
| -(BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch { | |
| NSLog(@"TAPPED"); | |
| //Touch gestures below top bar should not make the page turn. | |
| //EDITED Check for only Tap here instead. | |
| if ([gestureRecognizer isKindOfClass:[UITapGestureRecognizer class]]) { | |
| CGPoint touchPoint = [touch locationInView:self.view]; | |
| if(self.interfaceOrientation==UIInterfaceOrientationPortrait||self.interfaceOrientation==UIInterfaceOrientationPortraitUpsideDown) { | |
| NSString *imgURL = [NSString stringWithFormat:@"document.elementFromPoint(%f, %f).src", touchPoint.x, touchPoint.y]; | |
| NSString *urlToSave = [webV stringByEvaluatingJavaScriptFromString:imgURL]; | |
| NSLog(@"urlToSave :%@",urlToSave); | |
| NSURL * imageURL = [NSURL URLWithString:urlToSave]; | |
| NSData * imageData = [NSData dataWithContentsOfURL:imageURL]; | |
| UIImage * image = [UIImage imageWithData:imageData]; | |
| imgView.image = image;//imgView is the reference of UIImageView | |
| } | |
| } | |
| return YES; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment