即使应用程序以横向方式加载,iPad 上的所有视图也会以纵向模式启动

发布于 2024-11-13 10:07:10 字数 513 浏览 2 评论 0原文

我有一组非常复杂的嵌套视图控制器,其中一个(大约 5 层深)具有在启动时生成的定制面板。我有代码可以检测设备的旋转并相应地重新排列面板,因此纵向有 3 个面板宽,横向有 4 个面板宽。我通过使用宽度组件而不是检测方向来完成此操作。

重新定位面板的方法(uiscrollview)在旋转甚至启动时都可以完美工作,但只能在启动时获取纵向高度。

无论我如何检索宽度属性,它都会返回纵向宽度项目,我已经尝试了以下操作:

float frameWidth = mainPanel.frame.size.width;
float frameWidth = self.view.frame.size.width;
float frameWidth = [[[UIApplication sharedApplication] keyWindow] frame].size.width;

但仍然没有运气!

(主面板是一个 uiscrollview,设置为自动拉伸到笔尖的大小)

这是更好的方法吗?

I have a nicely complex nested set of Viewcontrollers, one of them (about 5 deep) has custom made panel's that are generated on startup. I have code that detects the rotation of the device and re-arranges the panels accordingly so there's 3 panels wide on portrait and 4 panels wide on landscape. I have done this by using a width component rather than detecting the orientation.

The method that re-positions the panels (uiscrollview) works flawlessly on rotation and even on start up but only gets the portrait height on startup.

No matter how i retrieve the width attribute, its returning the portrait width item, i have tried the following:

float frameWidth = mainPanel.frame.size.width;
float frameWidth = self.view.frame.size.width;
float frameWidth = [[[UIApplication sharedApplication] keyWindow] frame].size.width;

and still no luck!

(mainpanel is a uiscrollview that is set to autostretch to the nib's size)

Is this a better way to do this?

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文