Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Why not use the methods available for <a href="http://developer.apple.com/library/ios/#documentation/uikit/reference/UIViewController_Class/Reference/Reference.html" rel="nofollow"><code>UIViewController</code></a> itself?</p> <p>You could use these methods in your particular class according to the orientation you need.</p> <pre><code>- (BOOL)shouldAutorotate - (NSUInteger)supportedInterfaceOrientations - (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation </code></pre> <p>In your AppDelegate, you are already having this method, you don't need it anywhere else.</p> <pre><code>-(NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window { return UIInterfaceOrientationMaskAllButUpsideDown; } </code></pre> <p>From Apple Docs</p> <blockquote> <p>This method returns the interface orientations to use for any view controllers that do not specify their own explicitly. The orientations returned by this method are used if the view controller does not override the supportedInterfaceOrientations or shouldAutorotateToInterfaceOrientation: method.</p> <p>If you do not implement this method, the application uses the values in the UIInterfaceOrientation key of the app’s Info.plist as the default interface orientations.</p> </blockquote> <p><strong>Update if using <code>UINavigationController</code></strong></p> <p>In this case you need to implement the custom <code>UINavigationController</code> because your <code>navigationController</code> might disturb the interface orientations you have provided for different viewcontrollers.</p> <p><strong>CutomNavigationController.h</strong></p> <pre><code>#import &lt;UIKit/UIKit.h&gt; @interface CutomNavigationController : UINavigationController @end </code></pre> <p><strong>CutomNavigationController.m</strong></p> <pre><code>#import "CutomNavigationController.h" @interface CutomNavigationController () @end @implementation CutomNavigationController //overriding shouldRotate method for working in navController -(BOOL)shouldAutorotate { return [self.visibleViewController shouldAutorotate]; } -(NSUInteger)supportedInterfaceOrientations { return [self.topViewController supportedInterfaceOrientations]; } - (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation { return [self.topViewController preferredInterfaceOrientationForPresentation]; } </code></pre> <p>Finally use this <code>CustomNavigationController</code> in your <code>AppDelegate</code>, this will be referenced as your <code>navigationcontroller</code> for all the viewcontrollers</p>
 

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