Managing Interface Orientation ios 6 - iphone

I am facing some problems with my current application's interface orientation. My application need to run only in portrait orientation But I need to show the videos in both modes. So what I have done is I set the application to support all orientations both portrait and land scape in the project file. And in my view controller class (a base class for all view controllers in the project) I set the status bar orientation to portrait. It works perfectly for all view controllers except for that presented as modal view . Any solution for restricting land scape mode to those views??

You have to make custom class files subclass of UINavigationController to support rotation as per your requirement.
I had the same issue . Please follow it, you will get an idea.
Hope this will help.

Related

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.

iOS different Orientation modes with same application

I have a multitab application where I want the display orientation the same for one tab and dynamic for the other, that means I need for example for
Tab1 = always portrait orientation
Tab2 = automatic detection plus orientation
I have tried to disable the orientation on Tab1 but that will disable the orientation in the whole app.
Any help?!
From Apple docs:
"Tab bar controllers support a portrait orientation by default and do not rotate to a landscape orientation unless all of the root view controllers support such an orientation. When a device orientation change occurs, the tab bar controller queries its array of view controllers. If any one of them does not support the orientation, the tab bar controller does not change its orientation."
So the answer is no you cannot do what you are trying to do, it's an all or nothing kind of situation.
If you have not already used, I think calling different UIView for different Tab will help you to do so.
If you have used it, then making 2 different ViewControllers and handling the same thing different may help you to do so.

Custom Landscape/portrait view

I would like to have my buttons arranged a specific way for my portrait view and and different way for my landscape view. I would also like to be able to add things to my landscape view that might now have been in my portrait view. The reasons i know this is possible is obviously, the calculator app that comes with every iphone. When you tilt it sideways into landscape it gives you a whole new set of buttons. Does anyone know how to create a custom portrait view that is loaded when the iphone is right side up and how to create a custom landscape view when the iphone is on its side with different buttons?
You can try having two separate nib files for each orientation. You can customize the nib based on that.
Create two different view controllers (i.e. NIB files or items in your storyboard). Call the classes MyViewControllerLandscape and MyViewControllerPortrait.
Create a third view controller class programatically. Call it MyViewController, and make it the parent class of the landscape and portrait controllers.
This makes it so that you can put all the common code for the two controllers in the parent class and put only the orientation specific code in the other two.
Follow the instructions at http://developer.apple.com/library/ios/#featuredarticles/ViewControllerPGforiPhoneOS/BasicViewControllers/BasicViewControllers.html#//apple_ref/doc/uid/TP40007457-CH101-SW26 to see how to switch between the landscape and portrait viewControllers.

tabbar controller in landscape mode

I am working on a project in which I need to have the application in landscape mode. I made the changes in .plist file by setting interface orientation to landscape. I changed the orientation to landscape in the .xib files also but still when the application starts the in the simulator the tabbar controller appears in portrait mode only. Can any one please help with this.
Thanks
Note that by design, the UITabBarController will only rotate to support an interface orientation that all of its view controllers support. It will send the -shouldAutorotateToInterfaceOrientation: message to each of its view controllers and, if they all return YES, will return YES.