Make the UIWebview fill screen - iphone

How do I make the content in the UIWebView fill the whole screen? The UIWebView fills the iphones width correctly, however I need to doubletap the image in the UIWebview to make it stretch out to the bounds.
Help much appriciated!

Try setting scalesPageToFit to YES on your UIWebView.

Related

How to adjust webview inside a parent scrollview?

I have a ScrollView within which I am adding TextViews, ImageViews and a UIWebView. I am able to dynamically adjust the height of all these views except the UIWebView.
I have turned off the scrolling of the UIWebView, and want to resize the WebView according to its content. And at the same time resize the scrollview according to the resized WebView.
The scrollview should contain the resized WebView. I think there is much discussion about and around this but I haven't been able to reach a concrete solution. So any help would be appreciated.
here is what you can try
After you have loaded content in the UIWebView you can use it's stringByEvaluatingJavaScriptFromString: method to ask the html document for its height. This is a little tricky but should work.
You can do something like this:
NSInteger height = [[webView stringByEvaluatingJavaScriptFromString:
#"document.body.scrollHeight"] integerValue];
The scrollheight mught not be the best. You have a couple of options. Experiment with the document properties mentioned in http://james.padolsey.com/javascript/get-document-height-cross-browser/
after that u can resize you scrollview to the content,
this is the only method seems working, till now. Good- luck

Stopping a UIWebView from scrolling horizontally

I've a UIWebview displaying a .rtf file. The lines of text are wider than the screen.
1) Is there a way to get the text to wrap around rather than going off the edge of the screen and requiring the user to scroll.
2) Is there a way to disable horizontal scrolling in the UIWebView.
Many Thanks
Code
If you want the content to fit inside the view, set it's scalesPagesToFit property to true:
webView.scalesPagesToFit = YES;
If you do that, the pages shouldn't be horizontally scrollable. If they are, you can fiddle around with the stuff in UIScrollView Reference because UIWebView is a subclass of it.

How to set content offset and content size in a UIWebView

I have had to change a UIScrollView into a UIWebView due to formatting reasons.
There is a problem though that I need to be able to get the content offset back to 0, 0 (as I am using reusable UIWebViews and changing content) and get the content size so I can place a button at the bottom; but UIWebView does not seem to have this.
This problem can be solved quite easily:
[[webView scrollView] setContentInset:UIEdgeInsetsMake(64, 0, 44, 0)];
Remember that UIEdgeInset is different from CGRect!
A guide on UIEdgeInset can be found in the iOS Developer Library.
The best way I found to sort the problem was:
Create a UIWebView
Put it in a UIScrollView
Add the HTML into it using "loadHTMLString"
Using the "- (void)webViewDidFinishLoad:(UIWebView *)webView {" delegate method I detect the size of the UIWebView
Set the frame of the UIWebView to the content size.
Remove interaction from the UIWebView
Set the Content size of the UIScrollView to the content size.
Then used the functionality of the UIScrollView instead of the UIWebView.
Thanks
-JM
Use JavaScript.
I think that the next line should do the magic:
[webView stringByEvaluatingJavaScriptFromString:#"window.scroll(0,0)"];
Now you can ask for the contentSize property of the scrollView property of a UIWebView.
This enables you to also change the content size of that web view, using CGSizeMake (width, height).
Once you get the UIScrollView that is inside the UIWebView, it will be easy to change ContentOffset and contentSize. Information here on how to get the scrollView : ScrollOffset in UIWebView?

resize an image without UIScrollView

I want to resize an image without UIScrollView in iPhone application.
I want to use touchesMoved. How to do it?
Thank you
I usually load the image in a UIWebView instead of UIImageView, then you automatically get zoom/resize behaviour.
You can set the transform property of your UIImageView.

UIWebView is zooming when I resize it. Can I tell it to stop doing that?

I'm using a UIWebView to display formatted text. It works fine until I start resizing it. When I do it starts zooming and the font size gets too big. Is there anyway to tell it not to zoom or reset the zoom?
try setting the minimumZoomScale and maximumZoomScale of the uiwebview to 1.