0

My application requires to support both portrait and landscape mode except one view in portrait only. I found on forums that i have to subclass Navigation controller and then use SupportedInterfaceOrientations method to handle it.

But, my app has a different layout, there is a tabbar controller as rootview controller and then each tabbar controller has its own navigation controller. i also have a login view (for authentication in app) presented on the rootview controller. Now the problem is where should i add

- (BOOL)shouldAutorotate
{
   return NO;
}

- (NSUInteger)supportedInterfaceOrientations
{
   return UIInterfaceOrientationMaskPortrait;
}  

this code - in Navigation controller or Tabbar controller or in AppDelegate.

User382
  • 864
  • 19
  • 42
  • Which view is the one that is to be portrait only? Is it the login view? – matt Jul 21 '14 at 18:10
  • possible duplicate of [In iOS6, trouble forcing ViewController to certain interfaceOrientation when pushed on stack](http://stackoverflow.com/questions/15300819/in-ios6-trouble-forcing-viewcontroller-to-certain-interfaceorientation-when-pus) – matt Jul 21 '14 at 19:29

1 Answers1

0

Unless the view is the login view, you should add that code nowhere. iOS 7 does not support single children of tab bar controller or navigation controller having a special orientation.

In iOS 7, this will work for the login view if you put the code in the login view, because it is a presented view controller, and this configuration is supported for presented view controllers.

(In iOS 8, as it has been seeded up to this time, it won't work even for the login view.)

matt
  • 515,959
  • 87
  • 875
  • 1,141
  • That portrait only view is not login view, it is a view from Tabbar. Do you mean i cann't have one tabbar item only in portrait mode and other tabbar items in both portrait and landscape mode. – User382 Jul 21 '14 at 19:15
  • I do mean that. See, for example, my answer here: http://stackoverflow.com/a/15301322/341994 What I say about navigation controllers is equally true of tab bar controllers. What you're describing is possible only in iOS 5 and earlier. – matt Jul 21 '14 at 19:26
  • How to create for example Landscape view only apps if above is true. If you specify Supported Device Orientation in Info.plist then it should get applied to all views no matter if it is a tabbar or navigation bar or a model view. – User382 Jul 21 '14 at 20:14
  • That is correct. If the whole app is limited to landscape, the whole app is limited to landscape. But if one view will appear in portrait, you can't do that: the whole app must allow landscape and portrait. And in that case, no view except a presented view can _force_ rotation. Read the answer I pointed you to, please. And see my full explanation here: http://www.apeth.com/iOSBook/ch19.html#_rotation – matt Jul 21 '14 at 20:16