user1028028
user1028028

Reputation: 6433

Support portrait in iOs except for one view controlelr

I have an iOs project that needs to support all orientations on iPad and on iPhone I need to support only portrait on all view controllers EXCEPT one that needs to support all orientations and autorotate.

I tried:

#pragma mark - Should Rotate device
- (NSUInteger)supportedInterfaceOrientations
{
    if ([[DeviceInfo sharedInstance] is_iPhone]) {
        return UIInterfaceOrientationMaskPortrait;
    } else {
        return UIInterfaceOrientationMaskAll;
    }
}

But that method doesn't get called... How should I do this?

Upvotes: 0

Views: 46

Answers (3)

user1028028
user1028028

Reputation: 6433

The problem was solved by implementing the methods on the navigation controller that owns all the views

Upvotes: 0

nikhil84
nikhil84

Reputation: 3207

If my understanding is right then I have given answer for this query so u could follow this link.

Do let me know if any doubt.

Okay so got solution for your iOS 7 as below method write down in appDelegate class.

- (NSUInteger) application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window {

  if ([[[[[[UIApplication sharedApplication] keyWindow] rootViewController] childViewControllers] lastObject] isKindOfClass:[ViewController class]])   //Here you could provide your view controller and provide orientation which u want for that particular view controller.
  {
    return UIInterfaceOrientationMaskPortrait;
  }
  else
  {
    return UIInterfaceOrientationMaskLandscape;
  }
}

This will help you out for iOS 7.

Upvotes: 1

gran33
gran33

Reputation: 12981

Why don't you select the wanted ones here:

enter image description here

Select your app in project navigator -> general -> select your target -> scroll down to deployment info.

Upvotes: 1

Related Questions