Pergunta

I have an html page that I am trying to display via a UIWebView inside my iOS app. Everything is working fine, except I can't view the entire page on the screen. I only see the top left corner, and then I have to scroll either down or to the right to view the remaining page. I do want to point out that the image that is on the HTML page is the size of a full page, which is most likely the reason why the entire HTML page does not fit on the iOS screen.

Here is my iOS code (which is very straightforward):

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    [webView loadRequest:[NSURLRequest requestWithURL:[NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"arabic" ofType:@"html"] isDirectory:NO]]];
}

and here is the HTML code I am trying to display:

<html>
<head>
<title>My Title</title>

<style type="text/css">

#container {
    position:relative;
}
#highlight {
    position:absolute;
    width:325px;
    height:55px;
    top:230px;
    left:475px;
    background: rgba(255, 0, 0, 0.4);
}

</style>

</head>
<body>

<div id="container">
    <img src="myImage.png" />
    <div id="highlight"></div>
</div>

</body>
</html>

Can anyone see what I am doing wrong, and what I can do to view the entire page on the screen?

Foi útil?

Solução

The scalesPageToFit property of UIWebView might be what you're looking for. According to the documentation,

If YES, the web page is scaled to fit and the user can zoom in and zoom out. If NO, user zooming is disabled.

Hope this helps!

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top