iPad 应用程序中 UIView 框架更改坐标
强文本我有一个 iPad 应用程序,它只允许横向方向,并以横向方向启动。我有一个 UIViewController ,在 viewDidLoad 中我设置了视图的框架:
self.view.frame = CGRectMake(0, 0, 1024, 728);
在同一个 UIViewController 中的 touchesBegan 函数中code> 我打印出视图:
NSLog(@"%@",self.view);
当我点击屏幕时得到:
<UIView: 0x37e370; frame = (0 0; 768 1024); transform = [0, 1, -1, 0, 0, 0]; layer = <CALayer: 0x37e3d0>>
如您所见,框架更改为 [0,0,768,1024] (这是纵向 iPad)而不是 [0,0,1024,728] (这是我在 viewDidLoad 方法中定义的)。
为什么它会针对我?
strong textI have an iPad app which only allows landscape orientation, and launches in landscape orientation. I have a UIViewController
and in the viewDidLoad
I set the frame of the view:
self.view.frame = CGRectMake(0, 0, 1024, 728);
In a touchesBegan
function in that same UIViewController
I print out the view:
NSLog(@"%@",self.view);
and when I tap the screen get:
<UIView: 0x37e370; frame = (0 0; 768 1024); transform = [0, 1, -1, 0, 0, 0]; layer = <CALayer: 0x37e3d0>>
As you can see, the frame changes to [0,0,768,1024] (which is portrait iPad) instead of [0,0,1024,728] (which is what I defined it to be in the viewDidLoad
method).
Why is it switching on me?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这与你的另一个问题有关,不是吗? iPad Landscape 开始弄乱触摸
引用你的答案:
”的一点是,在定义UIWindow时,需要将其定义为
而不是严格的坐标。
”
This is related to this other question of yours, no? iPad Landscape messing up touches began
Quoting your answer:
" is that, when defining the UIWindow, it needs to be defined as
and not strict coordinates.
"