shouldAutoRotate接口问题与设置帧有关

时间:2011-05-31 19:22:07

标签: iphone objective-c ipad

我有以下内容:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    float xCenter;
    float yCenter;
    if (interfaceOrientation == UIInterfaceOrientationPortrait || interfaceOrientation == UIInterfaceOrientationPortraitUpsideDown){
        NSLog(@"PORTRAIT ORIENTATION");
        xCenter = 384;
        yCenter = 512;
        self.username.center = CGPointMake(xCenter, yCenter-60);
        self.password.center = CGPointMake(xCenter, yCenter+10);
        self.login.center = CGPointMake(xCenter, yCenter+110);
        self.box.center = CGPointMake(xCenter, yCenter);
        self.info.center = CGPointMake(xCenter, yCenter+70);
        self.logo.center = CGPointMake(xCenter, yCenter-600);
    }
}

NSLog正确打印,但它没有设置所有中心。我必须将方向改为横向,然后再回到肖像以使其生效。为什么是这样?如何让它影响第一次加载/应用程序启动?

1 个答案:

答案 0 :(得分:0)

在任何轮换之前调用

shouldAutorotateToInterfaceOrientation:。调用它来验证支持哪些方向以查看是否需要旋转。您必须使用列出的方法here