iOS:切换到横向模式时 Webview 不缩放

发布于 2024-12-29 10:41:44 字数 398 浏览 4 评论 0原文

自从升级到 Xcode 4.2 以来,当我更改方向时,Web 视图无法正确缩放,

我使用此代码:

NSLog(@"Show link: %@",URL);

[showStory loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:URL]]];

showStory.scalesPageToFit = YES;

showStory.contentMode = UIViewContentModeScaleAspectFit;

但是当我切换到横向模式时,会发生这种情况。有什么建议吗?

在此处输入图像描述

Since upgrading to Xcode 4.2, web views do not scale correctly when I change orientation

I use this code:

NSLog(@"Show link: %@",URL);

[showStory loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:URL]]];

showStory.scalesPageToFit = YES;

showStory.contentMode = UIViewContentModeScaleAspectFit;

But this happens when I switch to landscape mode. Any suggestions?

enter image description here

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

太阳男子 2025-01-05 10:41:44
Try this

 webView.scalesPageToFit = YES;
        webView.contentMode = UIViewContentModeScaleToFill;
        webView.multipleTouchEnabled = YES;
        webView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
        [self.view addSubview:webView];
Try this

 webView.scalesPageToFit = YES;
        webView.contentMode = UIViewContentModeScaleToFill;
        webView.multipleTouchEnabled = YES;
        webView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
        [self.view addSubview:webView];
温柔嚣张 2025-01-05 10:41:44

您需要在 webView 属性检查器中勾选比例页面以适应选项。

You need to tick the scales page to fit option in the webView Attribute inspector.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文