1

I have a app which i want to display in portrait mode. But I only want to show one view in both modes.

I have do this for iOS5 . But in iOS6,i can't able to do this.

I also tried many codes to solved it.

i use navigation in my app & rotate only one view in both mode is not possible in ios6. Either you fixed your rotation for a view or rotate whole app. Am i right?

How can I solve this problem?

user1673099
  • 3,293
  • 7
  • 26
  • 57

2 Answers2

1

in ios6 have you trying with this in plist like bellow image:-

enter image description here

and you can also set at xcode->projectname->summary:-

enter image description here

Nitin Gohel
  • 49,482
  • 17
  • 105
  • 144
  • Thanks for reply..but i also want to show one view in landscape mode so i select all orientation in summary – user1673099 Jan 29 '13 at 05:32
  • yes you can put autoration for only one view in Landscap and you can also impliment Catagory of NavigationController to suport actuly and currect oriation – Nitin Gohel Jan 29 '13 at 05:33
  • can you post some code How to do that? I want to show only one view in both mode & others are in only portrait mode. – user1673099 Jan 29 '13 at 05:37
  • http://stackoverflow.com/questions/12520030/how-to-force-a-uiviewcontroller-to-portait-orientation-in-ios-6 – Nitin Gohel Jan 29 '13 at 05:41
  • i try code But when i rotate in landscape then all views are display landscape. I just enable both mode for only one view. – user1673099 Jan 29 '13 at 05:49
1

From Apple's iOS 6 SDK Release Notes:

Autorotation is changing in iOS 6. In iOS 6, the shouldAutorotateToInterfaceOrientation: method of UIViewController is deprecated. In its place, you should use the supportedInterfaceOrientationsForWindow: and shouldAutorotate methods.

More responsibility is moving to the app and the app delegate. Now, iOS containers (such as UINavigationController) do not consult

their children to determine whether they should autorotate. By default, an app and a view controller’s supported interface orientations are set to UIInterfaceOrientationMaskAll for the iPad idiom and UIInterfaceOrientationMaskAllButUpsideDown for the iPhone idiom.

A view controller’s supported interface orientations can change over time—even an app’s supported interface orientations can change

over time. The system asks the top-most full-screen view controller (typically the root view controller) for its supported interface orientations whenever the device rotates or whenever a view controller is presented with the full-screen modal presentation style. Moreover, the supported orientations are retrieved only if this view controller returns YES from its shouldAutorotate method. The system intersects the view controller’s supported orientations with the app’s supported orientations (as determined by the Info.plist file or the app delegate’s application:supportedInterfaceOrientationsForWindow: method) to determine whether to rotate.

The system determines whether an orientation is supported by intersecting the value returned by the app’s

supportedInterfaceOrientationsForWindow: method with the value returned by the supportedInterfaceOrientations method of the top-most full-screen controller. The setStatusBarOrientation:animated: method is not deprecated outright. It now works only if the supportedInterfaceOrientations method of the top-most full-screen view controller returns 0. This makes the caller responsible for ensuring that the status bar orientation is consistent.

For compatibility, view controllers that still implement the shouldAutorotateToInterfaceOrientation: method do not get the new

autorotation behaviors. (In other words, they do not fall back to using the app, app delegate, or Info.plist file to determine the supported orientations.) Instead, the shouldAutorotateToInterfaceOrientation: method is used to synthesize the information that would be returned by the supportedInterfaceOrientations method.

If you want your whole app to rotate then you should set your Info.plist to support all orientations. Now if you want a specific view to be portrait only you will have to do some sort of subclass and override the autorotation methods to return portrait only.

See this example How to force a UIViewController to Portrait orientation in iOS 6

EDIT:

Solutions:

@implementation UINavigationController (Rotation_IOS6)

-(BOOL)shouldAutorotate
{
    return [[self.viewControllers lastObject] shouldAutorotate];
}

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

- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
    return [[self.viewControllers lastObject] preferredInterfaceOrientationForPresentation];
}

@end
Community
  • 1
  • 1
DD_
  • 7,230
  • 11
  • 38
  • 59
  • it can't be solved through a few lines of code, you can see the solution in the link I referred at the bottom, did't you check this? – DD_ Jan 29 '13 at 07:17
  • can i post my code?? I refer your link but it did not help me – user1673099 Jan 29 '13 at 07:19
  • If you want all of our navigation controllers to respect the top view controller you can use a category so you don't have to go through and change a bunch of class names...make sense? – DD_ Jan 29 '13 at 07:24
  • how can i make subclass of NavigationController class – user1673099 Jan 29 '13 at 07:24
  • Dont you know categorising? – DD_ Jan 29 '13 at 07:26
  • see http://mobile.tutsplus.com/tutorials/iphone/objective-c-categories/ and do this in case of your navigation controller and add the code I had shown, then it will work.thats all I can help – DD_ Jan 29 '13 at 07:29