UIWebView frame resize does not resize the inner content - iphone

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

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!

What do you have set for the webview's UIViewContentMode (can also be set in IB under the View section's "Mode")? Since you're resizing the view it may have something to do with this. Just a shot in the dark since I haven't tried it but hopefully this helps.
You may also want to try turning off scalesPageToFit before the transition and turning it back on after.

Related

Shrinking webpages that are shown in your UIWebviews

In my app I load some webpages in a 480*320(landscape) UIWebView. But the text is too large, well really the whole content of the page is too big.
Is there some trick that you can do to scale down the whole page in the web view so that it does not seem completely out of proportion to the rest of the app?
I'm guessing there is not and that the only way is to get the HTML of the whole page and look for Font tags and change them all to something smaller and then loading it into a UIWebView.
Thanks for any suggestions or ideas you can offer,
-Code
The UIWebView property scalesPagesToFit should work:
myYebView.scalesPagesToFit = YES;
From the UIWebView documentation:
You can also use the scalesPageToFit property to programmatically set the scale of web content the first time it is displayed in a web view. Thereafter, the user can change the scale using gestures.

Remove horizontal movement / wiggle from iPhone optimized pages

I'm trying to optimize our News pages for iPhone. One problem I've noticed is that I'm able to tap and move the page horizontally (i.e. wiggle).
My question is, how I can prevent this horizontal movement from happening?
All of our News pages have this problem. Here are a couple examples:
With picture
Without picture
Something is definitely set greater than your device width. Add the following to your css to find the culprit.
* {
border-style:solid;
}
You can then narrow down your search by setting border-color:red; to individual classes/tags/ids.
Add "overflow-x: hidden" on the body.
You can try setting user-scalable=0; and see if that has any effect.
This just happened to me too and it was the result of an extra closing div tag. Once I removed the extra </div>, the horizontal "wiggle" didn't happen any more.
I too, had the iPhone "wiggles" on a web page. It ended up being caused by an image that was wider than the column width it sat in (it was the last column in the row using Twitter Bootstrap). You might be thinking "obvious", but it's hard to spot when the image background matches the page background.
Just make the image responsive, or smaller than the column width - that solved it for me.
Taking the idea from other websites, most of big sites have a mobile site. look at those (the only one i know is facebook m.facebook.com) you can maybe see how the css is done. possible way of doing this is %. I would suggest to take out the sidebar for the mobile version. big pictures should be taken out or be resized so the browser doesn't have scroll bar side to side.

How to use a UIScrollview with a few images

I have not used a UIScrollView before, and I just wanted to know how I could use paging in a UIScrollView, where there would be a different image on each page, and depending on the page currently selected I would set the image on that page to a separate UIImageView's image.
So if anyone could tell me how to do this that would be great.
The Snipplr reference here gives you a great barebones look into how to set this up.

iPhone Mobile Safari: Portion of content scales by it self

Really, wondering and don't know why, on the initial load, the "<'p'>" element that holds content is scaled up, the fontsize, if i change orientation of the device it will then adjust scaling and keep it at declared font size that originally was intended, but that initial load. any ideas why?
I had a similar problem and the answer that worked for me was:
This is because sometimes Safari webview Zooms text automatically when
it thinks its a good idea.
To disable this behavior add this to your body CSS Style:
-webkit-text-size-adjust:none;
Are you sure loading CSS portion before content?

UIWebView With PDF

I'm displaying a PDF file using UIWebView, and I want to do 2 things:
I want to make the page fit the phone screen without the user has to double tap to do that
I want to remove the margin with gray shadow around the displayed PDF
Thanks for helping
I don't think this will help much, but I think your best option is to render the PDF to an image (of decent DPI) and show the image instead. I do this for an app, but we do that server side using ImageMagick - don't know how you might do that in obj-c. Also note that a mostly-text PDF will be much larger (filesize) when rasterized.
However, you might also try to embed the PDF in HTML page and load that HTML in the WebView - that may at least avoid the gray border/artboard.
webView.transform = CGAffineTransformScale( webView.transform, 1.25, 1.25 );
2 - Checking the Scale Pages to Fit box in IB sorted this for me
I would also like to know the answer to 1.
I guess you want to know how to display the PDF in the same way as when opening as attachment in mail, where the navigation bar only appears on a tap and the status bar also disappears?
You can also use Quartz to do it, as explained here : http://developer.apple.com/iphone/library/documentation/GraphicsImaging/Conceptual/drawingwithquartz2d/dq_pdf/dq_pdf.html
Where has CGAFFineTransformScale been all my life?
Seriously, that is a big help. However, it worked better applying it to webView.scrollView.
Finally, is there a similar command to change the offset of the content as well as the scale?