Sudha Tiwari
Sudha Tiwari

Reputation: 2461

Issues in iOS 6.0 rotation

I am making an app which would be in both modes portrait as well as landscape. For iOS 5.0 I am adding views by following way i.e.

 -(BOOL)shouldAutorotateToInterfaceOrientation: (UIInterfaceOrientation)interfaceOrientation

{
   if(((interfaceOrientation == UIInterfaceOrientationLandscapeLeft) ||
    (interfaceOrientation == UIInterfaceOrientationLandscapeRight)))
{
    productname.frame=CGRectMake(240, 97, 106, 20);
            self.view = landscapeView;

}

else if

(((interfaceOrientation == UIInterfaceOrientationPortrait) ||
          (interfaceOrientation == UIInterfaceOrientationPortraitUpsideDown))){
    productname.frame=CGRectMake(153, 151, 106, 20);

    self.view = portraitView;

}

   return YES;

}

But for iOS 6.0 I got following two methods for orientation,

I actually need a method which must fire during rotation of device. If anyone has an idea please let me know. I already wasted alot of time on it.

Thanks a lot in advance.

Upvotes: 2

Views: 144

Answers (2)

Vishal Singh
Vishal Singh

Reputation: 4490

use

-(void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration

Upvotes: 0

iiFreeman
iiFreeman

Reputation: 5175

I'm using UINavigationController subclass with following code:

    - (BOOL)shouldAutorotate {
    return YES;
}

- (NSUInteger)supportedInterfaceOrientations {
    if (self.topViewController.presentedViewController) {
        return self.topViewController.presentedViewController.supportedInterfaceOrientations;
    }
    return self.topViewController.supportedInterfaceOrientations;
}

- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation {
    return self.topViewController.preferredInterfaceOrientationForPresentation;
}

and it's work perfect for me

and in AppDelegate.m file:

- (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window {
    return [UIDevice isIpad] ? UIInterfaceOrientationMaskAll : UIInterfaceOrientationMaskAllButUpsideDown;
}

Upvotes: 1

Related Questions