开发者

shouldAutoRotateToInterface issues with setting up frames

开发者 https://www.devze.com 2023-03-09 07:58 出处:网络
I have the following: - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation

I have the following:

- (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 = CGPoin开发者_如何学GotMake(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);
    }
}

The NSLog prints correctly however it does not set all the center's. I have to change orientation to landscape and then back to portrait to have this into effect. Why is this? How do I make it to affect on the first load/app launch?


shouldAutorotateToInterfaceOrientation: is called prior to any rotations. It is called to verify which orientations are supported to see if it needs to rotate. You will have to use the methods listed here.

0

精彩评论

暂无评论...
验证码 换一张
取 消