UISplitViewController and orientation - iOS < 5.0

烂漫一生 提交于 2019-12-01 17:31:53

If I remember correctly, iOS misreports the actual orientation until the first rotation.

Also IIRC, using [[UIApplication sharedApplication] statusBarOrientation] circumvents this problem.

Ram

After removing the login view from the window set the rootviewcontroller direction according to the orientation of device using following code.

#define DegreesToRadians(x) ((x) * M_PI / 180.0)

[LoginviewContoller.view removeFromSuperview]

self.viewController = [[[ExampleViewController alloc] initWithNibName:@"ExampleViewController" bundle:nil] autorelease]; 

switch(self.viewController.interfaceOrientation)

{ 
case UIInterfaceOrientationPortrait:             
    NSLog(@"potrait");            
    break;
case UIInterfaceOrientationPortraitUpsideDown:
    NSLog(@"prtraitdown");
    break;
case UIInterfaceOrientationLandscapeLeft:
    self.viewController.view.transform =  
    CGAffineTransformMakeRotation(DegreesToRadians(270));
    NSLog(@"lanscapelef");
    break;
case UIInterfaceOrientationLandscapeRight:
   self.viewController.view.transform = CGAffineTransformMakeRotation(DegreesToRadians(90));
   NSLog(@"landcsape righ");
   break;
}

[self.window addSubview:self.viewController.view];

It will load the Rootviewcontroller according to the device orientation.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!