UISplitViewController and orientation - iOS < 5.0
Asked Answered
R

2

6

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 try presenting login/reg view from the viewdidAppear method of splitViewController's rootview, it is not showing up. I tried presenting the login/reg view from the Appdelegate's didFinishLaunching method using the following code

[self.window.rootViewController presentModalViewController:self.navController animated:NO]; 

and it works.

My problem is, the application supports both the landscape orientations, but when i run it in the device, no matter in which orientation i hold the device, I get only LandscapeRight as orientation. So if i hold the device in LandscapeLeft orientation, app lauches with login screen upside down. I am using LandscapeLeft & Right in supported orientations on the info.plist.

Please help me resolve the issue. Also how will we present a view when we have splitViewcontroller as the rootview of the app?

In iOS 5.0 (only) I am able to present the login view from the splitviewcontroller's rootview controller - viewdidAppear method. In all other OS versions, this case is not working and i need to present it from the Appdelegate's didFinishLaunching method.

Robson answered 5/1, 2012 at 6:21 Comment(2)
In the controller for the login screen have you implemented - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation for the two orientations you desire?Ange
The correct way should be from your splitViewController's viewDidAppear method, which you said works on iOS 5. Can you provide the source for that so we can see how it looks? Maybe something in there could be done differently.Garris
F
0

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

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

Filling answered 16/1, 2012 at 17:40 Comment(0)
P
-1

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.

Preciado answered 16/5, 2012 at 14:26 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.