iPad框架宽度和高度混合在风景中 [英] iPad frame width and height mixup in landscape

查看:92
本文介绍了iPad框架宽度和高度混合在风景中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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

但是view.frame.size.height仍然是1024,这是设备处于纵向时的高度,当界面旋转时宽度和高度切换值?

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?

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

(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)

我肯定在iPhone上的宽度和高度开关,所以为什么不在iPad上?

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)

一旦奖金被授予答案,我将开始获得250的额外奖励并奖励它是同一个人。

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

推荐答案

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

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

您应查询视图的边界而不是其 frame 位于定义视图的坐标(外部世界)中,因此在旋转时可以保持不变。 bounds 是在视图内部及其子视图中使用的坐标。旋转时会发生这种情况。

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.

这篇关于iPad框架宽度和高度混合在风景中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆