为什么仿射缩放 UIWebview 会给出奇怪的结果?

发布于 2024-12-26 18:47:11 字数 1039 浏览 3 评论 0原文

我有一个 HTML5 游戏,我希望将其包含在 UIWebview 中。

我首先使用仿射变换旋转视图,但结果偏离了目标,而且尺寸也很糟糕。我决定将框架设置为封闭视图的框架。正如其他人发现的那样,这不是一个好的解决方案< /a>.所以我遵循了串联建议,然后遇到了一个奇怪的问题,在旋转和平移之后,游戏显示良好,但是一旦我想要缩放,游戏就开始行为异常(我得到迷幻的颜色......),这是当然不是预期的结果。

CGAffineTransform rot = CGAffineTransformMakeRotation( M_PI/2.0);
CGAffineTransform tran = CGAffineTransformMakeTranslation(0, [self statusBarFrameViewRect:self.view].size.height );
CGAffineTransform tranAndRot = CGAffineTransformConcat(rot, tran);

CGAffineTransform scale = CGAffineTransformMakeScale(self.view.frame.size.height, self.view.frame.size.width);
webView.transform = CGAffineTransformConcat(tranAndRot, scale);
// [webView setScalesPageToFit:YES]; // this line seems to do strictly nothing useful to me, whether on or off. 
//I hoped it would help the contents of the view to eventually size to the scaled view, if needed.

有谁能指出我正在做的事情是愚蠢的吗?

I have a game in HTML5 I wish to enclose inside a UIWebview.

I first rotated the view with an affine transform, but it was then off the mark and badly sized. I decided to set the frame to the enclosing view's frame. It was not a good solution, as others have found. So I followed the concatenation suggestion, and I got into the curious problem that after rotating and translating, the game displays fine, but as soon as I wish to scale, the game starts misbehaving (I get psychedelic colors...), which is not of course the intended result.

CGAffineTransform rot = CGAffineTransformMakeRotation( M_PI/2.0);
CGAffineTransform tran = CGAffineTransformMakeTranslation(0, [self statusBarFrameViewRect:self.view].size.height );
CGAffineTransform tranAndRot = CGAffineTransformConcat(rot, tran);

CGAffineTransform scale = CGAffineTransformMakeScale(self.view.frame.size.height, self.view.frame.size.width);
webView.transform = CGAffineTransformConcat(tranAndRot, scale);
// [webView setScalesPageToFit:YES]; // this line seems to do strictly nothing useful to me, whether on or off. 
//I hoped it would help the contents of the view to eventually size to the scaled view, if needed.

Does anyone has a pointer to what I'm doing that's stupid?

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

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

发布评论

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

评论(1

溺渁∝ 2025-01-02 18:47:11

最终我始终没有找到核心问题,这可能与游戏设计者使用的工具(Unity)有关。

因此,我的解决方案是在横向模式下完成整个 UI,并完全放弃旋转/平移部分。

In the end, I never found the core issue, which is probably linked to the tools used by the game designers (Unity).

Hence my solution was to do the whole UI in landscape mode and drop the rotate/translate part entirely.

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