Stretch WebView - webview

I'm stuck on making a gif element which inherits from WebView. This "WebView" is representing the following html => String.Format(#"<html><body><img src='{0}'/></body></html>", value); where value is the URL to the GIF.
However, when I declare it with a local gif, it does work, but the focus of the webview is at the top/left. I can also move/scroll the view of the webview which overflows the limits of the screen..
So, how can I make this WebView stretch about the screen?

For your WebView make sure you have the Horizontal and Vertical Options set to stretch it to the entire screen.
<WebView HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand" />
For your gif you will probably want the below to stretch your gif to the entire visible area.
<html><body><img src='{0}' style='width:100%;height:100%;'/></body></html>
If you want the WebView to only be the size of what inside it, then unless you want to get into some complicated javascript callbacks, I would just get the size of the gif and set the width and height request on the WebView.

Related

Zooming and UIWebView

I am having a problem with UIWebView. My application displays pdfs from local memory and displays them in a webView in fullscreen mode. By default, when the page loads, the content is apparently set to fit horizontally, which cuts off some of the bottom of the pdf. I would like it to initially show up vertically fit and horizontally centered. I have looked for an answer to this question for quit some time and can't seem to find anything.
Any ideas?
(Please do not suggest scalesPageToFit. Although it fixes many beginning problems, this is not one of them.)
uiWebView.scrollView property has the ability to set zoom and also manage display of content
UIScollView class ref

Scale UIWebview with content of page scaling with it

I am trying to mimic the tabbing system of the mobile safari app. When you go into tab mode, it looks like the page is shrinking. In my app, i have tried 3 different ways to achieve this effect.
1) capture image of the UIWebView, hide the web view and scale the image.
2) scale the UIWebView
3) apply a transform to the web view.
The first way is one of the best, except if i rotate the screen, the image is funky looking, because it ether expands the image, or shrinks the image.
The second way doesn't work, The web view does skink but it basically just zooms in on the web view content, so if your on google.com, it would zoom into the google logo or somewhere on the page, instead of keeping how it looks when not zoomed, and shrinking that.
The third way also works! except using transforms i don't see a way of controlling the x, y, width and height of the web view. i can add a translation or scale it, but with rotation, it doesnt work that well.
for portrait size of the web view on an iPhone 5 im trying to make it (64, 91.5, 192, 315), and landscape CGRectMake(113, 65, 341, 161). How can I fix this to make it scale right?
The transform approach is likely to be the best; when you apply a transform to a layer (including indirectly via the view) you instruct the GPU to do something special when compositing it. So you have free rein to do whatever you want without the view's logic on how to fit things into a particular space having any effect. As it's all a composition effect, the original pixel rendering of the view is unchanged.
However, when you rotate the device you want to adjust the view itself because what you actually want is for the web view to relayout content.
If you're just literally emulating Safari then use the view's frame to set the normal full screen layout; when you want to show the zoomed out view also apply a scaling transform and create a suitable paged scrollview to swipe between pages. If the device rotates then that should affect the frame and the scrollview but not the transform.

How can I prevent the scaling of a UIWebview's content after reorientation?

I'm building an iOS 5/6 app that has a UIWebView. It loads some HTML that I have embedded in my app.
Now when I rotate my device, the WebView changes its size (as I want it to fill the entire width of the screen).
And then it gets weird: some content gets scaled up and some content doesn't get scaled up. See this image with some example text in it:
As you can see, the header (H6) stays the same, while the paragraph gets scaled up. Does anybody have an idea how to prevent this? I want the html to look the same in landscape as it does in portrait mode.
I've tried setting the viewport scaling to 1: <meta name="viewport" content="initial-scale=1.0,max-scale=1.0">
but that doesn't help. The body's font-size style is set to 14px, but changing that to 14pt or a percentage also made no difference. Setting the width of the body to 100% also didn't help.
Strangely, removing the line break (<br/>) that's in the text fixes it but I need line breaks to be in there so that's no solution.
The only thing that does work is reloading the UIWebView's content after an orientation change, but that doesn't prevent it from looking wrong during rotation, and it resets any scrolling that the user may have done.
Any ideas?
Try this:
body {
-webkit-text-size-adjust: none;
}
I'm not sure, but it might be the scalesPageToFit propertie on your UIWebView.
If you are coding on XCode (I assume that because you are using UIWebView)
Choose the UIWebView on the nib.
Ultilities pane > Size inspector > in the Autosizing box, remove both double-direction arrows.
The UIWebView now has fixed size and won't automatically scale to orientation.
Is this what you want?

Resizing the content of UIWebView?

A noob here so it might take a while to understand what's the wrong, just follow along ..
the key purpose of my app is to download an xml file from rss feed then parse it and pass it as html file to a webview with this method: [webView loadHTMLString:aString baseURL:nil]
after the content took place in the webview it doesn't fit nice and neat instead there's some photos in the content that has a width larget than what it can be displayed at once without scrolling horizontally,as well as the attachments at the end of the webview you have to scroll a bit right or left to read the full name of it, it'd be nice if the content stretched so it can be seen without scrolling horizontally.
Notice that I adjusted webview property scalesPageToFit to be YES, but that scaled the content to very small size to the point that you can't read what it contains!
any solution around this?
You need to use a meta/viewport tag and se the content width. See documentation, here:
https://developer.apple.com/library/archive/documentation/AppleApplications/Reference/SafariHTMLRef/Articles/MetaTags.html

Resizing button on PDF page pinch

I am developing pdf application in iPhone. I am loading PDF page on view and UIview is on UIScrollView.
On pdf page i am adding custom button. Now i want to resize button on pdf page pinch. PDF pinch cause only resize button but . currently my PDF page is also resizing along with button.
So how to resize button on PDF page pinch?
Any help
Thanks
At the moment you're adding everything on the UIScrollView. You want to add your button to a different view layer that's on top of UIScrollView, but not within. This is a bit more complex, as you need to change the object position on every position/zoom change of the scrollview - but there are enough delegates so that this can be achieved pretty easy.

Resources