0

I have following ViewControllers:

InformationViewController and cardViewController.

How can i make sure that informationViewController is in portrait mode and cant be rotated.

Then cardViewController should be in landscape mode and cant be rotated.

How can i implement this in each viewController. i've at the moment activated protrait, landscape right and left in General

user3423384
  • 667
  • 2
  • 8
  • 18
  • 1
    While some of the answers below will help you answer this, I am just providing the friendly reminder that this kind of thing is against user interface recommendations. It provides for poor UX to force the user to rotate the device between views unless there is a very clear and explicit need for it. While it is certainly possible that you have a valid use for this, just re-think the use case and determine whether or not you really want this. – mrosales Apr 01 '14 at 21:12

3 Answers3

0

In informationViewController:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    // Return YES for supported orientations
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}

In cardViewController:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    // Return YES for supported orientations
    return (interfaceOrientation == UIInterfaceOrientationLandscape);
}
Stonz2
  • 6,306
  • 4
  • 44
  • 64
  • Yes, that stops the view controller from rotating to the "forbidden" orientation. But it does not make the device rotating the view when one of them is pushed over the other or later poped back. – Hermann Klecker Apr 01 '14 at 20:47
0

Have a look at my answer to this question: Force controllers to Change their orientation in Either Portrait or Landscape

(But don't use the deprecated methods. There are newer methods available which work either.)

It is easy to limit the view controllers to certain orientations. But see the other answer for how to force the device to actually rotate. Without that trick: If a portrait only view controller becomes visible while the device is in landscape, then it will be displayed in landscape regardless how you limit its supported orientations.

Community
  • 1
  • 1
Hermann Klecker
  • 14,039
  • 5
  • 48
  • 71
0

In Information view controller

- (BOOL)shouldAutorotate

{

    return YES;
}


- (NSUInteger)supportedInterfaceOrientations

{

    return UIInterfaceOrientationMaskPortrait;
}

And in card view controller

- (BOOL)shouldAutorotate

{

    return YES;
}


- (NSUInteger)supportedInterfaceOrientations

{

    return UIInterfaceOrientationMaskLandscape;
}

Note: Please be sure in project general setting tick the both portrait and landscape modes in device orientation (Deployment Info)

Hermann Klecker
  • 14,039
  • 5
  • 48
  • 71