Landscape mode for Xcode using storyboard - iphone

I´m making an app for a Zoo, and it is very simple, but because at fisrt I tried to make it with code and using xcode 3.2, but I had some problems so I started it with Xcode 4.3 and am trying it with the storyboards.
My question is, how could I put all the app in landscape mode? I mean I already set it in the infoplist: the initial interface orientation, and then in the .m file I changed the following:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return UIInterfaceOrientationLandscapeRight;
}
But it doesn´t work. When I add a tabbarcontroller and link it all the views become portrait. The first one if I rotate it it does give me the landscape but all the others are always in portrait, so what can I do?

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

When you add tabbar controller on storyboard, in attribute inspector of tab bar you have orientation that is on inferred by default, change it to Landscape. But is better you set orientation from summary tab of project to Landscape Right. it lets your up come up on Right landscape.

Related

I have an app with portrait support only , but i want to play video in MPMoviewController in both Portrait as well as Landscape, How to do it

I have an tab bar and navigation based app with portrait support only , but i want to play video in MPMoviePlayerController in both Portrait as well as Landscape, How can I do this
Try supporting all the orientations in your project properties and returning NO from the below method in all ViewControllers except the one you wanted to show Landscape.
-(BOOL)shouldAutorotate
{
// return YES for the desired View controller. :)
}
Also if you are using UINavigationController the app will use its rotation logic

iPad orientation issue in iOS 5

I have UISplitViewController in StoryBoard that is initial view and I want the app to work only in Landscape mode.
I have restricted orientation to landscape only, and even put in plist Initial interface orientation to Landscape (right home button).
In iOS 6 everything works fine, it shows master and detail view only, but in iOS 5 it is stuck in Portrait mode and only shows Detail view.
Please help me with this, I am stuck with it for last 2 hours...
You need to implement shouldAutorotateToInterfaceOrientation in the view controllers you have contained in the UISplitViewController:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation {
return UIInterfaceOrientationIsLandscape(toInterfaceOrientation);
}

Rotate only one view controller in a tabbed application

I've read to many posts but I can't find a solution.
I've a tabbed application using storyboard. All the View Controllers of that Tabbed Application must show the content in portrait orientation, but there's only one viewcontroller (which is showing a video) that I want to be in landscape mode.
EXPLANATION OF THE STORYBOARD: TabBarController -> 4x Navigation controllers -> each navigation controller points to his ViewController -> one of these view controllers have an image, when I press that image, i've done a push to another view, the view that I want to have in landscape mode because I have there a UIWebView to show a video.
I'm unable to have all the app only in portrait orientation and the viewcontroller mentioned capable to rotate in landscape mode.
My app is also supporting iOS 5, so I know there are methods deprecated and I'm getting crazy.
I believe that in Summary > iPhone / iPod Deployment info > Supported Interface Orientations > there I've to check Portrait, Landscape left and right, and then via methods, enable or disable the rotations. I'm lost.
Can you help me?
I think you should be able to do this if you push to the view as a modal. Make sure your application's PList file (under Supporting Files folder) is set to support all orientations and then simply add the code to the modal view controller to display landscape with something like this.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOr‌​ientation
{
return (interfaceOrientation == UIInterfaceOrientationLandscapeLeft);
}
Let me know if you have any luck.
As i worked out for my App i advise you to use this solution.By using some conditions in the shouldAutorotateToInterfaceOrientation method orientation type we can solve this.Just try with this link will help you.
https://stackoverflow.com/questions/12021185/ios-rotate-view-only-one-view-controllers-view/15403129#1540312

Pushing portrait view controller onto landscape view controller?

I am trying to push a portrait only view controller onto a controller that allows portrait or landscape. The issue I'm having is that if the user is in landscape mode and I push the new controller on it will remain in landscape mode and just look all screwed up. How do I force the orientation to change to portrait as the new view controller is pushed on?
KDaker's answer is correct but another option you can think about is whether you can limit navigation when your orientation isn't what you want. This isn't necessarily a good idea but there are situations where it can work well. An example would be if you had a video which when rotated to landscape became full screen and covered your navigation back button until it returns to portrait.
in iOS 5 and anything before you cant 'force' an orientation from one view to another. You can support only one orientation for the project but then allow autorotation. So in your case, you can only allow autorotation and wait for the user to rotate the device.
In iOS 6, they have changed the way orientation handling works, and its become alot more flexible. You now have these methods:
- (NSUInteger)supportedInterfaceOrientations
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
Using these, you can present your view controller in any orientation you prefer, given that it is supported in the former method.
hope this helps.

Why doesn't my view display in Landscape instead of Portrait mode?

I use to define my UIViews programmatically, setting the orientation via code. I haven't touched Interface Builder in a while and I've decided to go for the new Storyboarding system.
I was pretty happy until I found out that although I have set, in the inspector pane, the appropriate view controller to "Landscape", it never displays in another mode than portrait.
I commented in and out the code in my custom view controller:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
// Return YES for supported orientations
return (interfaceOrientation == UIInterfaceOrientationLandscape);
}
Nothing changes.
My View Controller is itself "under" a Navigation Controller on the Storyboard, so I suspect interference, and it's only the second view in the flow, so the fact that the application itself is defined as portrait should not interfere.
I am looking for ideas to test for at this point, since the application is stripped to so little code I really can't begin to guess where to look?
What supported orientations have you specified in Info.plist? In order for a UINavigationController to support rotation, all of it's child view controllers must also support rotation to the same orientation.