Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UIWebView frame resize does not resize the inner content

if I change the frame of a UIWebView (scalesPageToFit property is YES), what do I have to do that the zooming level of a currently displayed webpage persists?

Let's say I have a UIWebView frame with a width of 200 pixels, and has zoomed into a website so that only one column is visible. After changing the width to 300, I still see the column with the same size, and additional space at the left and right. But what I would need is that I still only see this column, but bigger.

Any ideas what I have to do to achive this? I tried a lot of things, but nothing worked so far.

By the way, the iPhone built in Safari browser does exactly this thing (with the same website, so it's not content related) when rotating the iPhone... I see the same content, bug bigger, NOT more content as it happens with my current version of code.

Thanks for helping! Markus

like image 512
Markus Gömmel Avatar asked Dec 17 '09 15:12

Markus Gömmel


1 Answers

EDIT: Better answer:

mjdth is correct, you can use the contentMode property on the UIWebView. Very simple:

webView.contentMode = UIViewContentModeRedraw; 

Old, crap answer:

This worked for me, but I was working with local pages and small amounts of content:

-(void)layoutSubviews
{
    // Cause web view to reload content in order to display at new frame size
    [webView reload];
}

I'd love to see a better solution that doesn't involve reloading the page though!

like image 169
Joseph Humfrey Avatar answered Oct 22 '22 00:10

Joseph Humfrey