Ios4 如何在单个视图中最好地处理纵向模式和横向模式?

Ios4 如何在单个视图中最好地处理纵向模式和横向模式?,ios4,screen-orientation,uiinterfaceorientation,Ios4,Screen Orientation,Uiinterfaceorientation,我目前的理解是,我必须在代码本身中指定坐标,而不是使用界面生成器。有更好的方法吗 目前我正在尝试处理登录视图。它在纵向模式下运行良好,但在横向模式下,几乎没有隐藏内容。请建议如何处理这个问题 谢谢 GuruPrasad R Gujjar。您可以通过以下两种方式之一处理此问题。第一个是您建议的并更改所有帧,第二个是在横向模式下创建一个单独的视图,并将其切换为旋转 对于这两种情况,您都需要实现这两种方法 - (BOOL)shouldAutorotateToInterfaceOrientation:(

我目前的理解是,我必须在代码本身中指定坐标,而不是使用界面生成器。有更好的方法吗

目前我正在尝试处理登录视图。它在纵向模式下运行良好,但在横向模式下,几乎没有隐藏内容。请建议如何处理这个问题

谢谢


GuruPrasad R Gujjar。

您可以通过以下两种方式之一处理此问题。第一个是您建议的并更改所有帧,第二个是在横向模式下创建一个单独的视图,并将其切换为旋转

对于这两种情况,您都需要实现这两种方法

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    return YES;
}
-(void) willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration{
    if (toInterfaceOrientation==UIInterfaceOrientationPortrait || toInterfaceOrientation== UIInterfaceOrientationPortraitUpsideDown) {
        //put the portrait orientation here
        self.usernameField.frame=CGRectMake(xPortraitLocation, yPortraitLocation, xWidth, yWidth);
        ...

    }
    else{
        //do the same thing with everything but for landscape mode
    }
使用单独的视图时,只需说出self.view=self.lanscapeView或self.graphicview,即可将其切换到其他视图

如果我要使用第一种方法,我有时喜欢在interface builder中创建一个假视图,这样我可以将所有项目放在正确的位置,并查看“位置”选项卡下的内容,这样就消除了对分配数字的猜测和检查

希望这有帮助