gpt4 book ai didi

iphone - 如何在 iPhone 上将 UIWebView 的内容居中

转载 作者:行者123 更新时间:2023-12-03 19:33:54 26 4
gpt4 key购买 nike

我在 UIWebView 中有一个 map 图像。它默认加载在左上角。我希望它在 UIWebView 的中心初始化。

有人知道怎么做吗?

谢谢!

最佳答案

如果 map 图像是页面中唯一的内容,它是否包含在 html 页面中?如果它至少包含在 body 标签中,您可以执行以下操作:

NSString *bodyStyle = @"document.getElementsByTagName('body')[0].style.textAlign = 'center';";
NSString *mapStyle = @"document.getElementById('mapid').style.margin = 'auto';";

[webView stringByEvaluatingJavaScriptFromString:bodyStyle];
[webView stringByEvaluatingJavaScriptFromString:mapStyle];

让我知道您的 html 的结构到底如何,然后我可以在必要时提供更多信息。

关于iphone - 如何在 iPhone 上将 UIWebView 的内容居中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2923534/

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