I am new to iOS. I developed one application, in my View i have lot of objects are there. When i am changing the iPad to landscape mode, all objects positions are changing. I mean all objects height and width and positions are also changed so i am getting problem with it. Now, should i change every object resolution or is there any direct methods to solve this problem. Please send me the code. Thanks in advance.
我是iOS的新手。我开发了一个应用程序,在我看来,我有很多对象。当我把iPad换成横屏模式时,所有的物体位置都在变化。我的意思是所有的物体的高度,宽度和位置也都改变了所以我也有问题。现在,我应该改变每一个物体的分辨率还是有直接的方法来解决这个问题。请把代码发给我。提前谢谢。
2 个解决方案
#1
0
You need to implement below:-
您需要在下面实现:-。
- (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
}
#2
0
If you want to support multiple orientations then you can specify the layout(s) using the old "springs and struts" system or you can use Autolayout. For the beginning with iOS7, take a look at this tutorial.
如果您想支持多个方向,那么您可以使用旧的“spring和struts”系统来指定布局(s),或者您可以使用Autolayout。从iOS7开始,看看本教程。
#1
0
You need to implement below:-
您需要在下面实现:-。
- (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
}
#2
0
If you want to support multiple orientations then you can specify the layout(s) using the old "springs and struts" system or you can use Autolayout. For the beginning with iOS7, take a look at this tutorial.
如果您想支持多个方向,那么您可以使用旧的“spring和struts”系统来指定布局(s),或者您可以使用Autolayout。从iOS7开始,看看本教程。