UISplitView Landscape Mode - ios

I have downloaded an example code from here and tested it out. The thing I wasn't able to understand is that when I set the orientation to Landspace only and run it in Portrait mode, nothing changes.. I mean I should still be able to see the menu on left and the Psychologist button shouldn't be there.
PS: With iOS6, it is working well but lower versions giving me the same result.

It looks like in the RoatatableViewController.m file the method
- (BOOL)shouldAutorotateToInterfaceOrientation:
Is telling the app that rotation is okay in all directions.
You should use this to block to landscape mode for iOS 5 and older:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return UIInterfaceOrientationIsLandscape(interfaceOrientation);
}
It just looks like the person who made this project up in Stanford overlooked this.

Related

Locking View Rotation to Landscape for whole app in ios 8.1

I'm new to IOS development, and I'm trying to write an app for deployment on an ipad. Partly to keep things simple, layout-wise, and because I believe that my users will only use the app in landscape mode, I wish to only allow landscape views, and completely disable portrait views.
I've found a good deal of advice looking around the internet for an answer. Unfortunately, none of it has worked for me. The best answer I've found was to simply to go the target in xcode, and under "deployment info" -> Device Orientation, simply uncheck "Portrait" and "Upside Down". This should, theoretically, solve my issue, but unfortunately, it does not. The view rotates just as normal to portrait mode.
Going to the info tab and setting the Initial Interface Orientation to Landscape (Left) does make the app at least start in Landscape mode, but it does not restrict it only to that mode.
Even adding
- (BOOL)shouldAutorotate {
return NO;
}
- (NSUInteger)supportedInterfaceOrientations {
return UIInterfaceOrientationMaskLandscape;
}
into my main view doesn't seem to help anything. So I'm somewhat stumped. There must be some setting or something somewhere which is still allowing portrait views. What might this problem be?
If you look at your AppName-Info.plist file, there should be a key titled 'Supported interface orientations'.
You should remove any of the Portrait values in that dictionary and make sure you only have the Landscape values included!
Edit:
In the question-asker's case, their issue involved a piece of code in the AppDelegate that changed the app's supported orientations.
- (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window
{
/* They had the following:
* return UIInterfaceOrientationMaskAll;
* Which allowed the orientation to rotate to portrait
*/
// This fixed their issue:
return UIInterfaceOrientationMaskLandscape;
}
Hope this helps!
You can do this in General tab in your project

iOS 3.2 to iOS 7 interface orientation inconsistency

I have a very old app that's compatible with iOS 3.2+ devices (both iPads and iPhones). And I have a big issue making it compatible with iOS 7!
In fact, it has been written long ago before ARC, storyboards and all that syntactic sugar we are pleased to play with nowadays. And I'm having a very hard time trying understanding some interface orientation issue:
For the iPhone, the app is only visible in landscape... No problemo with the main ViewController. But the settings one (a simple ViewController with a UITableView in it) is always displayed in Portrait !!! Whatever the properties I set and the methods I write.
In the .plist I have only supported orientations LandscapeLeft and Right. In the Settings View Controller, I have those methods:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
return UIInterfaceOrientationIsLandscape(interfaceOrientation) || (UI_USER_INTERFACE_IDIOM() != UIUserInterfaceIdiomPhone);
}
- (BOOL) shouldAutorotate {
return YES;
}
- (NSUInteger)supportedInterfaceOrientations {
return (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)?UIInterfaceOrientationMaskLandscape:UIInterfaceOrientationMaskAll;
}
But what really bothers me is that when I display self.interfaceOrientation it says Landscape (in the viewWillAppear, viewDidAppear and viewWillLayoutSubviews).
But the most weird, is that the status bar is in Landscape, over the Portrait ViewController!!!
(Of course, the problem appears both on device and simulator)
So if someone can help putting back that ViewController all in Landscape. Thanks in advance!
Well at last, I eventually found it!!!
The problem was (I still don't know exactly why) caused by the way I was switching between ViewControllers (the old iOS 3 way).
So to correct if, I test if the method presentViewController:animated:completion is available (God bless respondsToSelector:) and I use it when I can.
Problem solved!

Universal app not rotating on iPad but does on iPhone

I have just completed building a universal app which rotates perfectly on my iPhone, but on the iPad it just stands still.
Similar to this question, but that does not solve my issue.
The supported interface orientations are all set to allow rotation and I have even set this in my app delegate:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return YES;
}
- (NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskAll;
}
Still the iPhone rotates fine, but the iPad won't move from portrait.
What could cause this, or rather how can I fix it?
[UPDATE]
The switch on the side is not on lock.
The orientations in the PList are set correctly.
The Project settings (where you select it via buttons) are set correctly.
#adam-s was right, except with Xcode 7.x there is no button below the "devices" selector.
With Xcode 7, you need to change "Universal" to "iPad" whereby the orientation selectors change to reflect iPad-only settings. Then you can change the selector back to "Universal".
Confusing!
Don't forget to change the rotation settings for the target for both iPhone and iPad - note that there's an iPad button to the right of the iPhone one (which some people, such as myself, might miss at first glance):
I fixed this by adding this piece of code to every ViewController of mine:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return YES;
}
- (NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskAll;
}
It seems like this question's answer was correct after all. I just thought it wasn't since I checked through all the ViewControllers and found nothing restricting it from turning.

iPad App Portrait Only?

My app is entirely designed for IOS6. I use an xib for the iPhone and another one for the iPad. My AppDelegate sets up a TabBarController, though there is no class for the TabBarController itself. The TabBarController has two tab items, 1 a NavigationController, and 1 a View Controller, each of which has its own class. I would like the iPad to be able to run in just Portrait mode, upside down, and normal. On the summary tab of Target in Xcode, I have supported interface orientations set to Portrait and Portrait Upside Down.
My understanding with iOS 6 is that you only need to put
- (NSUInteger)supportedInterfaceOrientations
in the highest parent controller of a class, and set which Masks you would like it and all the child containers to work with. So, in the Root View Controller of the Navigation Controller I put:
- (NSUInteger)supportedInterfaceOrientations {
return UIInterfaceOrientationMaskPortrait|UIInterfaceOrientationMaskPortraitUpsideDown;
}
And in each of the child classes, I put:
- (BOOL)shouldAutorotate{
if( UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad )
{
return YES;
}
else
{
return NO;
}
}
I then put the same two methods in the 2nd Tab which was just a View Controller Class.
I installed the app on my iPad, and it worked fine in portrait mode, but did not rotate when I turned it upside down. I exited the app and turned the iPad upside down, but when I started the app again, it still stayed in the same spot. So, I killed the app completely, and started it from the beginning upside down. The splash screen was upside down, but when the screen disappeared, the app was still only showing in portrait mode, making the display upside down.
What am I missing?
click on appName select Target and just select the orientations which you want to support. thanks
The code above is great for pre iOS 6. For iOS 6 you have to use the mask orientation. If you want all of the views in iPad to rotate or just some you have the choice of using the above answer. If you want to hard code it the check my answer in the following link for a detailed code for autorotation of all masks or just rotate one view and let the others don't rotate. Any how here is the link
iOS 6 supportedInterfaceOrientations issue
The above answer is providing you with the right solution as well but if you want to learn how to code it check my answer in the link above. Happy coding.
Is the Rotation Lock enabled or not ? (If you are new to iOS, double tap the home button, and slide to the right: it's the little metal-styled button in shape of an arrow).
If you want to run your application to run on portrait mode only than,
1. Select Your Target.
2. In General -> Development Info -> Device Orientation Uncheck all other orientation.Portrait mode only should be checked.Than run your project.

IOS Device Orientation Stuck at Portrait mode, no Landscape

I'm using Xcode 4.3.2 and an iPad simulator 5.1
I really need some help with this, my app is stuck at portrait mode.
When I rotate the simulator
I've tried looking under the project settings and have these checked:
Portrait, Upside Down, Landscape Left and Landscape Right.
I also these methods in the view controllers:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return YES;
}
can anyone please help?
Check your supporting orientations in the project's settings or on *.plist file. Also, if you are using UITabBarController or smth else, all of your controllers have to support all orientations!
use cmd+shift+f and type - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
make sure all of them return YES if you want all orientations supported and NO For unsupported orientations
Make sure you only have one controller showing. I've seen this problem when I have multiple views with different controllers showing at the same time.
Yeah I had the same problem and the other answers here didn't fix my situation. I found I had to check the "Resize View from NIB" box in all the relevant views.
See screenshot below (although shows a slightly older version of XCode).

Resources