Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 07-17-2010, 12:45 PM   #1 (permalink)
Registered Member
 
Join Date: Jun 2010
Location: Bostonia
Posts: 53
evan1466 is on a distinguished road
Default UIWebView co-ordinates to capture an Image off a page.

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) doubleTapUITapGestureRecognizer *)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
}
evan1466 is offline   Reply With Quote
Reply

Bookmarks

Tags
uiscrollview, uiwebview

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 330
14 members and 316 guests
akphyo, alexP, appservice, bignoggins, EXOPTENDAELAX, flamingliquid, guusleijsten, Hamad, mariano_donati, ohmniac, Paul Slocum, Rudy, v1n2e7t
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,653
Threads: 94,115
Posts: 402,888
Top Poster: BrianSlick (7,990)
Welcome to our newest member, ohmniac
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 10:41 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0