UISplitViewController and orientation - iOS < 5.0

前端 未结 2 827
借酒劲吻你
借酒劲吻你 2021-01-18 08:00

I am using a splitviewcontroller as the rootview of my application. I need to show the login and registration views as a modal view on top of the splitviewcontroller. When i

相关标签:
2条回答
  • 2021-01-18 08:31

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

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

    0 讨论(0)
  • 2021-01-18 08:52

    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.

    0 讨论(0)
提交回复
热议问题