Muddu Patil
Muddu Patil

Reputation: 721

orientation support in TabBar application for iphone storyboard

I'm creating Tabbar application which is having 4 tabs, my FirstTabView should support to all orientation and all 3 tabViews should support only for portrait, when i change tab to SecondTabView it should forcibly change orientation to portrait is this possible in storyboard I used below code for FirstTabView.m

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return(interfaceOrientation == UIInterfaceOrientationPortrait || interfaceOrientation == UIInterfaceOrientationLandscapeLeft);
}

and in SecondTabView.m

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
    {
return(interfaceOrientation == UIInterfaceOrientationPortrait);
}

Its not allowing any tab view to support to landscape thanks in advance.

Upvotes: 0

Views: 402

Answers (3)

Mohammad Kamar Shad
Mohammad Kamar Shad

Reputation: 6067

if you were facing this problem on iOS6 In iOS6 Apple has Changed the way of managing the device orientation.apple introduces many new methods in it' s Documentation.And one of the changes done in its' documentation is

 - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation

apple has deprecated this method in iOS6 release .so this method can be remove from apple doc in future .if you want to manage device orientation.then you should implement new method introduced in iOS6. you should take a look of changes done in iOS6 release. link

i have a posted some piece of code you can try that one. it's easy to implement.

Please go through this Link

i think it may help you.

Upvotes: 0

Niru Mukund Shah
Niru Mukund Shah

Reputation: 4733

yes. it is possible with storyboard. For that you need to check which tab is selected. You can check it using

- (void)tabBarController:(UITabBarController *)tabBarController didSelectViewController:(UIViewController *)viewController;

In that apply the condition for your first viewcontroller where you want orientation. Set your orientation there or apply it in separate viewcontrollers.

Enjoy programming.

Upvotes: 0

Shineeth Hamza
Shineeth Hamza

Reputation: 1277

On iOS 5 or earlier versions each respective's tab's viewController must return YES from shouldAutorotateToInterfaceOrientation for the tabBarController to autorotate, not just the currently visible one.

Upvotes: 1

Related Questions