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

Mockup & CodeGen, iPhone & iPad
($9.99)

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

Manu
($0.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 12-20-2008, 06:48 PM   #1 (permalink)
Registered Member
 
Join Date: Aug 2008
Location: Ireland
Age: 21
Posts: 472
Default Set initial zoom/position of UIWebView

Hey,

I've been working with the UIWebView and want to know if there is a way to set the zoom extra when a page is loaded.

For example, I have a web page with a table on part of it. I want the user to be able to see only that table. I have unchecked 'enable user interaction' so the user cannot move about the page. How do I set the part of the page shown when it loads though.

Any help appreciated.
__________________
On the iOS App Store
kieran12 is offline   Reply With Quote
Old 04-23-2009, 05:19 AM   #2 (permalink)
Registered Member
 
Join Date: Dec 2008
Posts: 2
Default

Quote:
Originally Posted by kieran12 View Post
Hey,

I've been working with the UIWebView and want to know if there is a way to set the zoom extra when a page is loaded.

For example, I have a web page with a table on part of it. I want the user to be able to see only that table. I have unchecked 'enable user interaction' so the user cannot move about the page. How do I set the part of the page shown when it loads though.

Any help appreciated.
I know this is an old thread but I'm also tackling this issue. It would be really nice if I could zoom and pan to the portion of the website I'm interested in.

Thanks
pmseltmann is offline   Reply With Quote
Old 12-22-2009, 01:30 AM   #3 (permalink)
Registered Member
 
Join Date: Aug 2009
Posts: 126
Default

did you find any solution's??
rahul7star is offline   Reply With Quote
Old 08-08-2010, 07:27 PM   #4 (permalink)
Registered Member
 
Join Date: Jan 2010
Posts: 3
Default

I have just tried it using JS. and it works:

for zoom:
[webView stringByEvaluatingJavaScriptFromString:@"document. body.style.zoom = 5.0;"];


for scroll:
int scroll=20; //Pixels to scroll
NSString* s=[[NSString alloc] initWithFormat:@"window.scrollTo(0, %i)",scroll];
[webView stringByEvaluatingJavaScriptFromString:s];

Last edited by baba147; 08-08-2010 at 07:30 PM.
baba147 is offline   Reply With Quote
Old 08-09-2010, 04:30 AM   #5 (permalink)
Registered Member
 
Join Date: Dec 2008
Posts: 2
Default

A year late but thanks! I never ended up figuring that out!
pmseltmann is offline   Reply With Quote
Old 08-19-2010, 02:22 PM   #6 (permalink)
Registered Member
 
Join Date: Aug 2010
Posts: 1
Default

Quote:
Originally Posted by baba147 View Post
I have just tried it using JS. and it works:

for zoom:
[webView stringByEvaluatingJavaScriptFromString:@"document. body.style.zoom = 5.0;"];


for scroll:
int scroll=20; //Pixels to scroll
NSString* s=[[NSString alloc] initWithFormat:@"window.scrollTo(0, %i)",scroll];
[webView stringByEvaluatingJavaScriptFromString:s];

Nice, this does the trick.

However, there is still one small annoyance - you can see the zooming-in when the page loads. This is a pain when you navigate between pages. I tried disabling the 'Scale Pages To Fit' property of the WebView in Interface Builder, but then it won't zoom at all.

Any ideas on how to fix this?
iSveinn is offline   Reply With Quote
Old 09-28-2010, 06:39 PM   #7 (permalink)
Registered Member
 
Join Date: Nov 2009
Posts: 3
Default Set viewport

You set scalesPageToFit of UIWebView to YES
and
<meta name='viewport' content='width=device-width; initial-scale=2.0; maximum-scale=4.0; user-scalable=1;' />
in header of UIWebView, where these numbers are an example.

Good Luck!
iMagic is offline   Reply With Quote
Reply

Bookmarks

Tags
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: 353
22 members and 331 guests
ADY, Dani77, Duncan C, e2applets, Grinarn, HemiMG, Herbie, JasonR, keeshux, linkmx, macquitzon216, mer10, Monstertaco, prchn4christ, Promo Dispenser, Robiwan, sebasx, sly24, Touchmint, twerner, zulfishah
Most users ever online was 1,187, 10-11-2011 at 08:09 AM.
» Stats
Members: 158,881
Threads: 89,228
Posts: 380,760
Top Poster: BrianSlick (7,129)
Welcome to our newest member, macquitzon216
Powered by vBadvanced CMPS v3.1.0

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