iPad 横向框架宽度和高度混合
我已经完成了这个问题所说的:横向模式仅适用于 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您尚未指定要查询的“视图”。假设这是窗口的顶级子视图:
您应该查询视图的
bounds
而不是它的frame
。frame
位于定义视图的坐标(外部世界)中,因此在旋转时可能保持不变。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 itsframe
.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.我花了一段时间试图找出解决一个令人沮丧的问题的最简单的解决方案,这是我能想到的最好的解决方案。希望它能有所帮助。
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.