Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>First, you need to create a category:</p> <p>UINavigationController+Rotation_IOS6.h</p> <pre><code>#import &lt;UIKit/UIKit.h&gt; @interface UINavigationController (Rotation_IOS6) @end </code></pre> <p>UINavigationController+Rotation_IOS6.m:</p> <pre><code>#import "UINavigationController+Rotation_IOS6.h" @implementation UINavigationController (Rotation_IOS6) -(BOOL)shouldAutorotate { return [[self.viewControllers lastObject] shouldAutorotate]; } -(NSUInteger)supportedInterfaceOrientations { return [[self.viewControllers lastObject] supportedInterfaceOrientations]; } @end </code></pre> <p>Then, you implement these methods in your class that you want to be only landscape:</p> <pre><code>- (BOOL)shouldAutorotate { return YES; } - (NSUInteger)supportedInterfaceOrientations { return UIInterfaceOrientationMaskLandscape; } </code></pre> <p>In case you're using a UITabBarController, just replace the UINavigationController for UITabBarController. This solution worked nice for me after a long search! I was in the same situation as you are now!</p> <p><strong>EDIT</strong></p> <p>So, I saw your sample. You need to make some changes. 1 - Create a new class for the UINavigationController category. Name the class UINavigationController+Rotation_IOS6 (.h and .m) 2 - You don't need to implement the method <code>preferredInterfaceOrientationForPresentation</code>. Your category should look like this:</p> <pre><code>#import "UINavigationController+Rotation_IOS6.h" @implementation UINavigationController (Rotation_IOS6) -(BOOL)shouldAutorotate { return [[self.viewControllers lastObject] shouldAutorotate]; } -(NSUInteger)supportedInterfaceOrientations { return [[self.viewControllers lastObject] supportedInterfaceOrientations]; } @end </code></pre> <p>3 - In the class you want to rotate only in landscape, include this in the implementation, exactly like this:</p> <pre><code>// Rotation methods for iOS 6 - (BOOL)shouldAutorotate { return YES; } - (NSUInteger)supportedInterfaceOrientations { return UIInterfaceOrientationMaskLandscape; } </code></pre> <p>4 - I would advice to also include the method for autorotation for iOS 5 inside the class you want in landscape:</p> <pre><code>- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { return UIInterfaceOrientationLandscapeLeft | UIInterfaceOrientationLandscapeRight; } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload