更改 iPad 方向、旋转状态栏、工具栏,但不更改主视图

发布于 2024-09-19 07:23:40 字数 472 浏览 4 评论 0原文

我正在尝试设置一个基于窗口的 iPad 测试应用程序,其中我有一个视图控制器和一个视图。当我旋转 iPad 时,我希望工具栏的方向发生变化,而不是视图本身的方向发生变化。例如,您工作的某种背景视图固定在设备上,但状态栏和工具栏围绕它旋转。这将使用户能够从各个角度工作视图,但始终使用正确定向的工具集。

我想要的一个漂亮的实现可以在 iPad 应用程序的 Brushes 中找到,其中绘画的方向被锁定到设备,工具栏围绕它旋转。我认为其他绘画应用程序也能做同样的事情。

我一直在试图弄清楚如何做到这一点,但是在穷尽了许多其他有关方向的问题之后,我仍然不知所措。

有人能指出我正确的方向,找到一个简洁的解决方案吗? autoresizeMask 的自动调整大小的特定组合?用相反方向的另一个动画来对抗旋转动画?使用多个并发视图控制器,一个用于旋转视图,一个用于非旋转视图?

我非常感激,

(编辑:在 Olie 发表评论后试图澄清问题。)

I’m trying to set up an iPad test application, window-based, where I have a single view controller and a single view. When I rotate the iPad, I want the orientation of the toolbar to change, but not that of the view itself. For example, a sort of background view that you work in is fixed to the device, but the status bar and toolbars rotate around it. This would enable the user to work the view from all angles, but always with a correctly-oriented toolset.

A beautiful implementation of what I want can be found in the Brushes for iPad app, where the painting’s orientation is locked to the device, and the toolbars rotate around it. I think other painting apps do the same thing.

I’ve been trying to figure out how to do this, but after exhausting many many other questions here concerning orientation, I’m still at a loss.

Could anyone point me in the right direction towards a neat solution? A particular combination of autoresizes for the autoresizeMask? Countering the rotation animation with another one in the opposite direction? Using multiple concurrent view controllers, one for the rotating views and one for the non-rotating ones?

I’d very much appreciate it,

(Edit: Attempted to clarify the question, after Olie’s comment.)

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

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

发布评论

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

评论(3

你列表最软的妹 2024-09-26 07:24:20

就我所合作的范围而言,我看不到你的问题有任何简单的答案。旋转所有内容(选项卡栏、导航栏和状态栏、视图控制器)然后在“旧坐标”中重新绘制视图控制器的内容怎么样,这样对于用户来说它看起来就像没有旋转?

To the extent I have worked with I cannot see any simple answer to your question. What about rotating everything (tabbar, nav and status bar, your view controller) and then redrawing the content of your view controller in "old coordinates" so for the user it will look like it's not rotated?

东京女 2024-09-26 07:24:11

不久前我遇到了一个 bug,我很确定你所问的问题会导致 Apple 因 HIG 违规而拒绝你。不过,我会尝试记住问题是什么。我很确定它是这样的:

我有一个 tabbarViewController 说“我面向任何方向”。

其中一个选项卡是一个常规的旧 UIViewController,上面写着“我只做 LandscapeLeft 和 L-Right”。

当您旋转时,内部 (UIVC) 保持不变,但外部 (TabVC) 围绕物体旋转。

我可能有一些细节倒退或以其他方式令人费解,但总体思路是:堆叠的 VC,而不是所有的 VC。

祝你好运!

I had a bug that did this a while back -- I'm pretty sure that what you're asking will get you a HIG-violation rejection from Apple. However, I'll give a shot at remembering what the problem was. I'm pretty sure it was something like this:

I had a tabbarViewController that said "I orient to any orientation."

One of the tabs was a regular-old UIViewController that said "I only do LandscapeLeft & L-Right"

When you rotated, the inside (UIVC) stayed put, but the outside (TabVC) rotated around things.

I might have some of the details backwards or otherwise convoluted, but the general ideas is: stacked VCs, not all one VC.

Good luck!

梦境 2024-09-26 07:24:04

为了防止旋转,您可以将其放入视图控制器的 .m:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}

但您说您仍然希望视图框架调整大小以响应旋转。我自己不需要这样做,所以我不确定仅将 autoresizingMask 设置为具有灵活的宽度和高度是否足够;您可能还必须实现 didRotateFromInterfaceOrientation: 并使用 setNeedsLayout 和/或手动调整视图大小。

To prevent rotation, you'd put this in your view controller's .m:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}

But you say you still want the view frame to resize in response to the rotation. I haven't had a need to do this myself, so I'm not sure if it's sufficient to just set the autoresizingMask to have flexible width and height; you may also have to implement didRotateFromInterfaceOrientation: and use setNeedsLayout and/or resize the view manually.

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