I have been searching the web for any way to allow users to save an image off a web page into my game. Basically I am opening a page with a gallery of images in a UIWebview and using the code below which I found online to try to pull the URL. Similar to what Apple does to save images out of Safari.
Only problem is that the coordinate systems are off due to loading the web view zoomed in. UIWebview has no zoomScale property like a scrollview that I can find.
Anyone have any thoughts on how to translate the coordinates? If it were a scrollview I could just convert the points using offsets and the zoomscale...
- (void) doubleTap

UITapGestureRecognizer *)sender {
int scrollPosition = [[self.webView stringByEvaluatingJavaScriptFromString:@"window.pa geYOffset"] intValue];
CGPoint startPoint = [sender locationInView:self.webView];
NSString *
js = [NSString stringWithFormat:@"document.elementFromPoint(%f, %f).tagName", startPoint.x, startPoint.y+scrollPosition];
NSString *value = [self.webView stringByEvaluatingJavaScriptFromString:
js];
if ([value isEqualToString:@"IMG"]) {
NSString *imgURL = [NSString stringWithFormat:@"document.elementFromPoint(%f, %f).src", startPoint.x, startPoint.y+scrollPosition];
NSString *urlToSave = [self.webView stringByEvaluatingJavaScriptFromString:imgURL];
}
//Do whatever you want - like a UIAlertView or UIPopover to let the user chose what to do with the image
}