user1709502
user1709502

Reputation:

iOS 6 Orientation with Navigation Controller

I have an app that works fine on ios 5,im trying to upgrade my app to work on ios 6, i had read tons of questions and tutorials about using ios 6 orientation,

my problem is when i call my rootViewController its work fine with me, but when i push any viewController the orientation look so bad because i use the orientation to change the view sizes (my app support any orientation)

here is my code:

AppDelegate:


UINavigationController *nav =[ [UINavigationController alloc] initWithRootViewController:theView]  ;
self.window.rootViewController = nav;


- (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window  // iOS 6
{

return UIInterfaceOrientationMaskAll;


}




myFirstViewController:

-(NSUInteger)supportedInterfaceOrientations{

return UIInterfaceOrientationMaskAll;
 }

 -(void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration{

    [self viewWillAppear:NO];
 }

 -(BOOL)shouldAutorotate{
 return YES;
  }

- (void)viewWillAppear:(BOOL)animated
{

[super viewWillAppear:NO];
if ( [[UIDevice currentDevice].systemVersion floatValue] >= 6.0){
    if (pointRange.location != NSNotFound) {



UIInterfaceOrientation interfaceOrientation = [[UIDevice currentDevice] orientation];

if( (interfaceOrientation >= 3)  ) {
     width=1024;
    self.view.frame=CGRectMake(0, 0, 1024, 768);

}


if   ( (interfaceOrientation == 1) || (interfaceOrientation == 2 )) {

    width=768;
    self.view.frame=CGRectMake(0, 0, 768, 1024);


}}
....etc

and i did the same in my second view, Hope to find why!!

Upvotes: 1

Views: 1977

Answers (2)

user1909691
user1909691

Reputation: 11

You could always make an extension to the UINavigationController like this

@implementation UINavigationController (RotationFix)

-(NSUInteger)supportedInterfaceOrientations
{
    return [self.topViewController supportedInterfaceOrientations];
}

-(BOOL)shouldAutorotate
{
    return YES;
}

@end

Upvotes: 1

vishy
vishy

Reputation: 3231

even i suffered for 2 days.. gone through many tutorials, blogs, forums, even apple docs.

So far i came to know, In iOS 6 each template of the app should be handled in a different ways.

So far the discussions were only for view based app, and these changes were not working on navigation based app or tabBar based app.

Finally i got the solution, it like this

Implement a subclass of these two types UITabBarController or UINavigationController.

Got to know from this blog. Thanks to Shabbir for the solution.

Upvotes: 0

Related Questions