iPad orientation change issue

后端 未结 2 575
别跟我提以往
别跟我提以往 2020-12-29 15:38

My iPhone application is displaying some odd behavior when run on the iPad with respect to supporting orientation changes.

The app starts up with a view controller (

2条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2020-12-29 16:32

    Here is some code i'm using to prevent that error:

    - (void)viewDidLoad {  
        if (self.interfaceOrientation == UIInterfaceOrientationPortrait) {
            self.view.transform = CGAffineTransformIdentity;
            self.view.transform = CGAffineTransformMakeRotation(M_PI/2);
            self.view.bounds = CGRectMake(0.0, 0.0, 480, 320);
        }
        [UIView commitAnimations];
    }
    

    and

    - (void)viewDidLoad {
        if (self.interfaceOrientation == UIInterfaceOrientationLandscapeRight) {
            self.view.transform = CGAffineTransformIdentity;
            self.view.transform = CGAffineTransformMakeRotation(-(M_PI / 2));
            self.view.bounds = CGRectMake(0, 0, 320, 480);;
        }
        [UIView commitAnimations];
    }
    

    Based on what orientation the device is in, you will need to modify some of the code.

提交回复
热议问题