iPad 1 showing portrait mode instead of Landscape - ios

I have an application on AppStore that has portrait Mode on iPhone and on iPad it works on landscape. However i am getting reports that it shows portrait on iPad 1 thus destroyed overall View.
Why is iPad 1 specifically showing Portrait mode?
The version of iPad is 5.1.1

In ios 6, the methods for supporting interface orientation has been changed. For supporting both interface orientation in both version, we need to check the os version and write code acoordingly.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
Support for new versions
- (NSUInteger)supportedInterfaceOrientations {
}
- (BOOL)shouldAutorotate {
}
In my View Controller i have the following:
- (NSUInteger)supportedInterfaceOrientations {
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation {
}
- (BOOL)shouldAutorotate {
}

Go and make sure ALL view controllers return the correct orientation modes they support. I've seen such behaviour in iOS 5 and if I recall correctly that was the reason.

I had a very similar from and I resolved it by changing the following code in AppDelegate.m-> applicationDidFinishLaunching:
[self.window addSubview:self.viewController];
to
[self.window setRootViewController:self.viewController];

Related

ios set specific orientation for specific views

I am making game which supports only landscape orientation but I am also using a library to share my game video but that share screen require portrait orientation , If I don't enable portrait orientation my game got crash but If I enable portrait orientation to avoid this crash then my whole game become useless by becoming portrait as it is only for landscape.
This is my game Landscape View as shown by figures below,
This is the Library Portrait View to Share video
My Game View after sharing video from library
Please help me How can I enable portrait orientation for this library to avoid crash
and my rest of the app always remain in landscape and it never goes to portrait orientation.
Thanks
Add the following method to your application's AppDelegate.m file:
// IOS 6
-(NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window {
return UIInterfaceOrientationMaskAll;
}
In both cases you must also make sure that you have added the landscape only orientation handling code to your game's main UIViewController.
// IOS 5
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation {
return UIInterfaceOrientationIsLandscape(toInterfaceOrientation);
}
// IOS 6
- (BOOL)shouldAutorotate {
return YES;
}
- (NSUInteger)supportedInterfaceOrientations {
return UIInterfaceOrientationMaskLandscapeLeft | UIInterfaceOrientationMaskLandscapeRight;
}
Try to implement orientation methods to your view controller.
https://developer.apple.com/library/ios/featuredarticles/ViewControllerPGforiPhoneOS/RespondingtoDeviceOrientationChanges/RespondingtoDeviceOrientationChanges.html
I hope this help you.
In the view controller you want to support orientation override supportedInterfaceOrientations method.
I did like this...
-(NSUInteger)supportedInterfaceOrientations {
return UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationLandscapeLeft | UIInterfaceOrientationLandscapeRight;
}

How to show MPMoviePlayerController in landscape mode

i am working on a app where I am required to show "MPMoviePlayerController" in landscape mode and portrait mode. But My whole app is required to support Portrait mode only. That is no landscape mode for any view other than for the "MPMoviePlayerController".
I tried few things given over stack overflow. Nothing worked in my case. Feels Stuck in the middle. But I have seen some of the app supporting suck kind of requirements.
I have to implement it for both iOS 6, 7
In my app am using "XCDYouTubeVideoPlayerViewController" for playing videos(playing the youtube videos)
Please Help
I had the same issue, and the following solved the problem:
First you need to allow the Landscape mode either, by checking the checkboxes at Target / General / Deployment Info / Device orientation, and then you have to disable Landscape orientation by code at every ViewController you use in your app.
#pragma mark - Set Supported Device Orientation
//For iOS6
- (BOOL)shouldAutorotate {
return NO;
}
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
return UIInterfaceOrientationPortrait;
}
- (NSUInteger)supportedInterfaceOrientations {
return UIInterfaceOrientationMaskPortrait;
}
//For iOS4 and iOS5
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
But don't disable landscape orientation for the XCYoutubeVideoPlayerViewController, so at fullscreen it can rotate to landscape.
I have another solution for this, It will work for all MPMoviePlayerController, below is my code
- (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)windowx
{
if ([[self.window.rootViewController presentedViewController] isKindOfClass:[MPMoviePlayerViewController class]] ||
[[self.window.rootViewController presentedViewController] isKindOfClass:NSClassFromString(#"MPInlineVideoFullscreenViewController")])
{
if ([self.window.rootViewController presentedViewController].isBeingDismissed)
{
return UIInterfaceOrientationMaskPortrait;
}
else
{
return UIInterfaceOrientationMaskAllButUpsideDown;
}
}
else
{
return UIInterfaceOrientationMaskPortrait;
}
}
What we basically do here is we enable Landscape orientation for all MPMoviePlayerController classes which are actually MPInlineVideoFullscreenViewController when you present it for fullscreen.
Hope this helps

Universal app supporting portrait and Portrait upside down, but rotation not happening on iPhone - UPDATED

My app is a universal application that supports portrait and portrait upside down orientations.
My app uses a UITabBarController that has UINavigationControllers for 3 UITabBarItems.
To support of of these, i have done the following things:
1) added "supported Interface Orientations" key accordingly for both devices
2) added the following code in app delegate and all other view controllers
- (BOOL)shouldAutorotate {
return YES;
}
- (NSUInteger)supportedInterfaceOrientations {
return (UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskPortraitUpsideDown);
}
Everything is going as expected in iPad, but on iPhone, only some of my views (not all) do not respond to change in Orientation..!! Why is this happening??
You should check that all of your view controllers have the rotation defined, and then you should add this to them:
-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
// Return YES for supported orientations
return YES;
}
If you're using a navigation controller, you should create a subclass .i.e. "MyNavController" with the instructions to rotate in its implementation:
- (BOOL)shouldAutorotate {
return YES;
}
- (NSUInteger)supportedInterfaceOrientations {
return (UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskPortraitUpsideDown);
}
and then use it:
MyNavController *navo = [[MyNavController alloc] initWithRootViewController:myRootController];
As far as I know upside down in portrait mode for the IPhone is not allowed, cause when a user receives a phonecall, the app is on hold and he has the phone upside down. Thats why apple does not want that.

iPad Orientation Not working as it should

I have released an app, and for some reason only some people are having an orientation issue with the app. Namely that it is opening in Portrait mode, and is un-rotatable from here where as the app is set up to only be allowed in LandscapeLeft and LandscapeRight. Most people aren't having this issue, however I've received a few complaints recently through our support page.
People with the issue seem to be on iOs 5.1 and iPad gen 1s, which is the lowest OS my app supports.
Here is the code handling the rotation:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
if(interfaceOrientation == UIInterfaceOrientationLandscapeRight)
{
return YES;
}
else
{
return NO;
}
}
And here is the .plist
http://tinypic.com/r/nnvfhz/6
Any suggestions would be great.
In iOS5, you must override the shouldAutorotateToInterfaceOrientation: method:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
// support all interface orientations
return YES;
}
This method was deprecated as of iOS 6, for which you should use these:
- (BOOL)shouldAutorotate {
// return whether autorotation is supported
return TRUE;
}
- (NSUInteger)supportedInterfaceOrientations {
// return the mask that represents the supported interface orientations
return UIInterfaceOrientationMaskAll;
}
Finally, I'll mention this method, since it's often applicable:
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation {
// set the preferred orientation of view controllers presented in full-screen
return UIInterfaceOrientationLandscapeRight;
}

iOS 6 autorotation in simulator varies from actual iOS 6 device

My app will not autorotate in the iOS 6 GM simulator but it does with the same version of iOS on the device. Could this be a simulator bug? The app is using deprecated autorotation methods, but they are working fine on the device itself which makes me wonder if the simulator APIs are different?
It should still work with the deprecated rotate methods, but you need to add the following to your didFinishLaunchingWithOptions: method:
self.window.rootViewController = yourRootViewController;
This tells the main window what view controller to send the rotate notifications to. This is new with the iOS 6.0 SDK.
This is what I added to get my app working again:
// Tell the system what we support
- (NSUInteger)supportedInterfaceOrientations {
return UIInterfaceOrientationMaskAllButUpsideDown;
}
// Tell the system It should autorotate
- (BOOL) shouldAutorotate {
return YES;
}
// Tell the system which initial orientation we want to have
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation {
return UIInterfaceOrientationPortrait;
}
Adding the following was not enough to make it work on the simulator:
- (NSUInteger)supportedInterfaceOrientations {
return UIInterfaceOrientationMaskAllButUpsideDown;
}
- (BOOL) shouldAutorotate {
return YES;
}
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation {
return UIInterfaceOrientationPortrait;
}
To make it work, I also added the following inside the didFinishLaunchingWithOptions function of the appDelegate class:
self.window.rootViewController = viewController;
I stopped getting the following error after this addition:
Application windows are expected to have a root view controller at the end of application launch
- (BOOL)shouldAutorotate {
return NO;
}
and set the supported rotations for the root view controller in the app plist file to only portrait.

Resources