gpt4 book ai didi

html - 尝试让 html 页面完整地出现在 iOS 模拟器中

转载 作者:行者123 更新时间:2023-11-29 03:56:55 24 4
gpt4 key购买 nike

我有一个 html 页面,我试图通过 iOS 应用程序中的 UIWebView 显示该页面。一切工作正常,但我无法在屏幕上查看整个页面。我只看到左上角,然后我必须向下或向右滚动才能查看剩余页面。我确实想指出,HTML 页面上的图像是整个页面的大小,这很可能是整个 HTML 页面不适合 iOS 屏幕的原因。

这是我的 iOS 代码(非常简单):

- (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]]];
}

这是我试图显示的 HTML 代码:

<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>

任何人都可以看到我做错了什么,以及我可以做什么才能在屏幕上查看整个页面?

最佳答案

UIWebView 的 scalesPageToFit 属性可能就是您正在寻找的。根据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.

希望这有帮助!

关于html - 尝试让 html 页面完整地出现在 iOS 模拟器中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16380412/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com