如何将方向更改为横向模式?

时间:2013-10-26 10:50:46

标签: objective-c ipad ios7 landscape-portrait

我是iOS新手。我开发了一个应用程序,在我的视图中我有很多对象。当我将iPad更改为横向模式时,所有对象位置都在变化。我的意思是所有物体的高度,宽度和位置也都改变了,所以我遇到了问题。现在,我应该改变每个对象的分辨率,还是有任何直接的方法来解决这个问题。请把代码寄给我。提前致谢。

2 个答案:

答案 0 :(得分:0)

您需要在下面实施: -

 - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
CGRect bounds = [[UIScreen mainScreen] bounds]; // portrait bounds
if (UIInterfaceOrientationIsLandscape([[UIApplication sharedApplication] statusBarOrientation])) {
    bounds.size = CGSizeMake(bounds.size.height, bounds.size.width);
}
        return YES
    }

答案 1 :(得分:0)

如果您想支持多个方向,那么您可以使用旧的"弹簧和支柱"来指定布局。系统或您可以使用Autolayout。对于iOS7的开头,请查看this tutorial

相关问题