0

I have an Universal App that supports all orientations in iPad and only potrait in iPhone / iPod. My code looks somewhat like this:

@implementation UIViewController ( interfaceOrientationHack )
  - (void) shouldAutorotateToInterfaceOrientation: ( UIInterfaceOrientation ) toInterfaceOrientation {
    if( iPad ) {
      return YES;
    } else if( toInterfaceOrientation == UIInterfaceOrientationPotrait ) { 
      return YES;
    } else return NO;
  }
@end

From one of my controllers, i launch a navigation controller as modal view controller

[ self presentModalViewController: c animated: YES ];

The issue currently is, the modal controller launches correctly in orientation, But when i change my orientation the the modal controller doesn't change its orientation, all the rest of the controllers behave correctly.

Any help will be hugely appreciated. Thanks in advance.

fallenland
  • 525
  • 2
  • 6
  • Have you implemented the interface shouldAutoratoteToInterfaceOriebtation: for your modal view controller? – Jose Cherian Mar 10 '11 at 17:04
  • i dont think that's required.. as its a category on a uiviewcontroller and it seems to have been rightly named as a Hack, for its never advisable to implement such a behavior in a category. However, is the method called when you rotate the modalview? – govi Mar 10 '11 at 17:30
  • Yes, he is trying to override the UIViewcontroller,s instance method using categary which is not recommended. But according to documentation, only method to implemnt view rotation is shouldAutororateToInterfaceOrientation. Since his other views are working fine, it is worth to give a try. – Jose Cherian Mar 10 '11 at 20:56
  • This is whats happening, i use categories to to define shouldAutoRotateToInterfaceOrientation. This method gets called almost everywhere except when Orientation is changed when modalViewController is presented. I can not fathom why? – fallenland Mar 11 '11 at 09:46
  • See this [question][1]! [1]: http://stackoverflow.com/questions/5267034/category-conflicts – YuAo Feb 27 '12 at 10:11

1 Answers1

0

From UIViewcontroller class reference:"By default, the UIViewController class displays views in portrait mode only. To support additional orientations, you must override the shouldAutorotateToInterfaceOrientation: method and return YES for any orientations your subclass supports. If the autoresizing properties of your views are configured correctly, that may be all you have to do."

Since your modal view inherits from UIViewcontroller, you have to override shouldAutorotateToInterfaceOrientation:in your modal view.

Jose Cherian
  • 7,207
  • 3
  • 36
  • 39