iPad App Portrait Only? - ios

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.

Related

iOS 8 Orientation Issues : Keyboard ends up in incorrect position

I have a universal project for iOS that was created in xCode 5 that I am trying to port to xCode 6. Everything seems to have been fine since I am not using LaunchScreen and iPhone 6 and 6 Plus scale the application to their resolutions.
The problem occurs when device changes its orientation.
Scenario:
It only occurs on iPhone 6 and 6 Plus.
Open Login screen with username and password fields. Rotate the device to Landscape, and tap username or password field. The keyboard appears in the middle of the screen with half cut. Rotating back to portrait hides the keyboard altogether and it no longer appears on screen no matter which field you tap on.
To get the keyboard back, rotate back to Landscape, tap on a field rotate device to opposite Landscape (don't let it go in Portrait). The keyboard suddenly becomes normal and acts fine.
I got the same problem, and that's because your app is launched in scaled mode.
It seems that Apple didn't go the full blown way to handle landscape in this scaled mode.
The solution is to switch to non-scaled mode for the iPhone 6-6Plus, using the trick specified here: How to enable native resolution for apps on iPhone 6 and 6 Plus?
Note that this will likely break a lot of your screens in the process.. but there's no other solution.
I have faced this issue with scalable mode of the app. Though supporting non-scalble mode (by adding iPhone 6 & 6+ launch images to xcassets) solves this problem, it was not permissible in my case as screens had static layout for each orientation.
I could solve this problem by avoiding the incidents of changing the root view controller of the window. Instead, the new view controllers have been added (with balancing removal) as subview (and hence childViewController) to the existing root view controller.
Everything is ok on iOS6/7, But not iOS8.
The orientation of the keyboard on iOS 8 is not the same as status bar.
If your application runs only portrait mode you can stop generating orientation notifications;
[[UIDevice currentDevice] endGeneratingDeviceOrientationNotifications];
I have faced this issue, and after some research I found some stuff, that caused such bug.
In my AppDelegate I changed window rootViewController to show different ViewControllers depends of authorization status
if (!auth)
{
self.window.rootViewController = [[AuthViewController alloc] init];
} else {
self.window.rootViewController = [[DataViewController alloc] init];
}
I removed this and move controller select logic to NavigationViewController
if (!auth)
{
self.viewControllers = #[[[AuthViewController alloc] init]];
} else {
self.viewControllers = #[[[DataViewController alloc] init]];
}
and make this NavigationViewController as Storyboard initial view controller.
Hope it helps!

iOS 8 Screen slides wrong direction when back button tapped

My application was written for iOS7 and I am trying to get it updated to iOS 8. My application is configured to only work in Landscape Left and Landscape Right orientations.
For iOS 8 I changed the order by which the screens are navigated and changed one of the modal screens to a push transition. On the main screen I have two UIBarButtonItems on the UINavigationItem. Each of these have a push segue assigned to them that connects to different screens.
When the app is running and one of the UIBarButtonItems is tapped, the screen associated through the segue slides over the main screen as expected. The back button is displayed normally. The problem occurs when the back button is tapped. The screen does not slide off to the right as would be expected.
On an iPhone 4 running iOS 7 the screen always slides down (towards the ground) regardless of the devices landscape left or landscape right orientation.
On an iPhone 6 Plus running iOS 8 the called screen quickly rotates to Upside Down (top towards the home button) and then slides off to home button side. Again it doesn't matter which way the phone is oriented landscape left or landscape right orientation.
I have tried setting the preferredInterfaceOrientationForPresentation, shouldAutorotate to NO, and setting the supportedInterfaceOrientations to UIInterfaceOrientationLandscapeRight | UIInterfaceOrientationLandscapeRight. Nothing seems to make any difference at all.
My screen navigation is straight forward, I'm no using any custom transitions. It's all through standard push segues.
I need to get the screen "back" transitions working correctly again.
Any help is greatly appreciated!
I have finally discovered what was causing my screens to slide the wrong direction. It turns out that overriding the supportedInterfaceOrientations method in the UIViewController and returning UIInterfaceOrientationLandscapeRight | UIInterfaceOrientationLandscapeLeft confuses the transition in iOS 8 (and devices running iOS 7 also). This was needed for proper operation in iOS 7, but evidently causes problems in iOS 8. So once I removed the code, the screen transitions began working correctly again.

Landscape-only IPad App With UISplitViewController

I am almost done developing an app. Right now I'm converting it to a universal app by supporting iPad to supported devices as well.
Can I set the app to use Landscape orientation only, since I am using UISplitViewController and want the Master View Controller to remain on the screen all the time? Is there any Apple policy that states that I cannot restrict it to Landscape only and I have to implement both portrait and landscape? Is there any chance my app can be rejected by setting it to Landscape only for iPad?
Don't worry, you'll be fine. Support both landscape orientations and neither portrait orientation if you want. I've got apps in the store that are like that.
However, note that UISplitViewController does have an option to keep both views on the screen all the time even in portrait. Use the delegate method splitViewController:shouldHideViewController:inOrientation: to forbid hiding the master view:
http://developer.apple.com/library/ios/#documentation/uikit/reference/UISplitViewControllerDelegate_protocol/Reference/Reference.html#//apple_ref/occ/intf/UISplitViewControllerDelegate
So if your only reason for being landscape only is that you don't want to hide the master view, it is a false reason. Look, for example, at Apple's Settings app, which works like that; it is a split view controller that always shows both views in all four orientations.

iPad app to start in landscape mode

I searched for other existing posts, but none of them satisfied my requirements.
Here is the problem i face,
My app supports both the Modes , landscape and portrait.
But my first screen only supports Landscape , so the app must start in Landscape.
I have set supported Orientation to all the 4 options
I have set the Initial interface orientation to Landscape (left home button)
In the view controller of the first screen i am defining the below
-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return (interfaceOrientation != UIInterfaceOrientationPortrait);
}
And when i start the app the simulator always opens in Portrait and my view is all messed up in the portrait mode , since it is designed only for the landscape.
After the switch to the Landscape, the device remains in this mode.
can anyone help me with the solution to avoid this ?
Thanks
Naveen
EDITED :
This info may be helpful , The problem is faced only when i hold the device in Portrait and then launch the app.
Its not the duplication of this question, Landscape Mode ONLY for iPhone or iPad
Landscape Mode ONLY for iPhone or iPad
I do not want my app to be only in Landscape , i want only the first screen of my app to be only in Landscape.
I did some experimenting with an app I'm working on that has the same requirements, and came up with the following:
To set the initial orientations that are supported when the app is first launched, use the "Supported Device Orientations" setting for your target.
Also back that up with the appropriate shouldAutorotateToInterfaceOrientation code, as you've already done.
For subsequent screens, simply use the shouldAutorotateToInterfaceOrientation code to determine which orientations you want to support. Even if you've specified only landscape modes for the Supported Device Orientation, shouldAutorotateToInterfaceOrientation wins. :)
I think this approach is a little cleaner than using an extra dummy VC.
I achieved a workaround for the Problem and it solved ,
I created a dummy view controller and added as the root view controller of the Window.
Added the below method in the implementation
-(void)viewDidAppear:(BOOL)animated
{
WelcomeScreen *welcomeScreen = [[[WelcomeScreen alloc] initWithNibName:#"WelcomeScreen" bundle:nil] autorelease];
[self presentModalViewController:welcomeScreen animated:NO];
}
Now it worked as expected.
Here is a SO link that will hopefully answer your question on how to launch your app in landscape mode.

How to force UIInterfaceOrientation?

I am writing an app and run into two problems. I have been searching the web all night without success and wonder if anyone here can help.
When the application starts, I want it to default to Landscape mode and Detect whether it is in UIInterfaceOrientationLandscapeLeft or UIInterfaceOrientationLandscapeRight. I have created the UI in landscape mode in the .xib file. However, when I check self.interfaceOrientation it always returns UIInterfaceOrientationLandscapeLeft regardless of whether the home button is on the left or right in the iPad simulator.
When the user rotates the iPad between the two landscape orientation, I want the view the change. To illustrate with a simplified example, if it is UIInterfaceOrientationLandscapeLeft, I want to write 1 on the left side of the screen and 2 on the right side of the screen. In UIInterfaceOrientationLandscapeRight, write 2 on the left side of the screen and 1 on the right side of the screen. Which method in iOS can tell me whenever the user rotates the device?
Thanks very much in advance.
Joe
Where are you checking that? If you're doing it in applicationDidFinishLaunching or in the view controller's viewDidLoad then it's likely the interface orientation isn't set properly yet. Wait until viewWillAppear or viewDidAppear to check that.
Take a look at shouldAutorotateToInterfaceOrientation in your view controller. You need to return YES to supported orientations so in your case you want to return YES if interfaceOrientation is landscape (there's a helper function for checking landscape vs portrait by the way). Also look at didRotateFromInterfaceOrientation which tells you when the user has rotated.
http://developer.apple.com/library/ios/#documentation/uikit/reference/UIViewController_Class/Reference/Reference.html

Resources