ios – 我的自我观点有错误的尺寸

我的观点有错误的尺寸.我正在运行景观,但视图报告纵向尺寸“查看宽度= 768.000000高度= 1024.000000”任何想法如何解决?我玩过我试过的自转器
- (BOOL)shouldAutorotatetoInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    return (interfaceOrientation == UIInterfaceOrientationLandscapeLeft|| interfaceOrientation == UIInterfaceOrientationLandscapeRight);
}

- (BOOL)shouldAutorotatetoInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    return YES;
}

它在视图上看起来很好,但尺寸确实与我的应用程序混乱.

解决方法

你永远不应该使用框架来告诉你自己的维度. frame相对于父容器视图.要查找与视图自身坐标系相关的维度,请使用bounds:self.view.bounds

例如,父视图可能会看到子视图的宽度= 768,高度= 1024,但旋转90度变换.这是父视图查看子视图的方式,这就是self.view.frame的内容.宽度= 1024和高度= 768的子视图反映在视图如何在自己的坐标系中看到自己,即self.view.bounds

相关文章

当我们远离最新的 iOS 16 更新版本时,我们听到了困扰 Apple...
欧版/美版 特别说一下,美版选错了 可能会永久丧失4G,不过只...
一般在接外包的时候, 通常第三方需要安装你的app进行测...
前言为了让更多的人永远记住12月13日,各大厂都在这一天将应...