iPad 横向框架宽度和高度混合

发布于 2024-09-17 20:30:21 字数 475 浏览 8 评论 0原文

我已经完成了这个问题所说的:横向模式仅适用于 iPhone 或 iPad

但view.frame.size.height仍然是1024,这是设备竖屏时的高度,肯定是界面旋转时宽高切换值吧?

(假设您想将屏幕分成 3 个视图,对于一个横向和纵向的应用程序,并且您执行了 view.frame.size.width / 3 ,在横向中这是不正确的,因为宽度值不正确实际上是宽度)

我确信在 iPhone 上宽度和高度可以切换,那么为什么不在 iPad 上呢?


这再次让我震惊,我也不使用笔尖,有人可以给出一个可以接受的答案吗? (即不涉及手动切换宽度和高度的)

一旦对答案授予赏金,我将开始另一笔 250 的赏金并将其奖励给同一个人。

I have done what this question said here: Landscape Mode ONLY for iPhone or iPad

but the view.frame.size.height is still 1024, which is the height when the device is in portrait, surely when the interface rotates the width and height switch values?

(say you wanted to split the screen into 3 views, for an app that is both landscape and portrait, and you did view.frame.size.width / 3 , in landscape that wouldn't be correct as the width value wouldn't actually be the width)

I'm sure on the iPhone the width and height switch, so why not on the iPad?


This has struck me again I 'm not working with a nib either, could someone please give an acceptable answer? (ie one that doesn't involve manually switch the width and height)

Once the bounty has been awarded to an answer, I will then start another bounty for 250 and award it to the same person.

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

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

发布评论

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

评论(2

箜明 2024-09-24 20:30:21

您尚未指定要查询的“视图”。假设这是窗口的顶级子视图:

您应该查询视图的 bounds 而不是它的 frameframe 位于定义视图的坐标(外部世界)中,因此在旋转时可能保持不变。 bounds 是视图及其子视图“内部”使用的坐标。当您旋转时,这确实会改变。

You haven't specified which "view" you're querying. Assuming this is the top level subview of the window:

You should query the view's bounds not its frame. frame is in the coordinate in which the view is defined (the outside world) hence may remain constant as you rotate. bounds is the coordinate used "inside" the view and for its subviews. This does change when you rotate.

孤单情人 2024-09-24 20:30:21
+ (int) currentWidth
{
 UIScreen *screen = [UIScreen mainScreen];
 int width = screen.currentMode.size.width;
 int height = screen.currentMode.size.height;
 return (UIDeviceOrientationIsLandscape([[UIApplication sharedApplication] statusBarOrientation]))? MAX (width, height) : MIN (width, height);
}

我花了一段时间试图找出解决一个令人沮丧的问题的最简单的解决方案,这是我能想到的最好的解决方案。希望它能有所帮助。

+ (int) currentWidth
{
 UIScreen *screen = [UIScreen mainScreen];
 int width = screen.currentMode.size.width;
 int height = screen.currentMode.size.height;
 return (UIDeviceOrientationIsLandscape([[UIApplication sharedApplication] statusBarOrientation]))? MAX (width, height) : MIN (width, height);
}

I spent a while trying to work out the simplest solution to a frustrating problem, and this was the best I could come up with. Hope it can help.

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