iOS 6 orientation changes have me totally confused - iphone

This is a universal app and I have the supported interface orientations for both iPhone and iPad targets set only to Landscape Left and Right. My root view controllers do not use a NavigationController and the xibs are landscape oriented views. The app is designed to only use the landscape orientations.
In application:didFinishLaunchingWithOptions I have...
if (([JLHelper isIPhone]) | ([JLHelper iPadPortraitRestricted])) {
application.statusBarOrientation = UIInterfaceOrientationLandscapeRight;
}
In iOS 5 everything worked fine but In iOS 6 the view does not display in a landscape orientation on startup.
I understand that shouldAutorotateToInterfaceOrientation has been deprecated in iOS 6, but I do not understand why this affects the initial presentation. It appears to me that the root view is being rotated.
I have read many discussions on how to force landscape orientation in iOS 6 and am now totally confused. There must be a simple way to implement an app that only uses landscape orientation.

You can specify the supported orientations in the info.plist for iOS 6. Additionally you can implement the shouldAutorotate method and the supportedInterfaceOrientations methods (new as of iOS 6) to conditionally restrict orientations for iOS 6.
Note that if you want to continue to support iOS 5 you also have to have the shouldAutorotateToInterfaceOrientation... method in place. iOS 5 uses the old method, iOS 6 the new one, they can coexist.

Related

Lock Orientation iMessenger App?

Is it possible to lock the orientation of an iMessenger App (iOS 10)?
I've tried using the .plist file to set the supported orientations but it doesn't work. I want to restrict the orientation to portrait but when I delete the landscape orientations from the .plist, the app still rotates.
No it is not possible. Apple has clearly said in the last WWDC that they want dev to support both orientations.

How to rotate cocos2D game into landscape mode in iOS 6?

I have an iPhone 4S (running iOS 5.1) & an iPhone 5 (running iOS 6.1). I noticed that when i try to open the cocos2D game, on the iPhone 4S running 5.1, the game is able to open perfectly fine in landscape mode.
However, when I try to open the same cocos2D game on my iPhone 5 running 6.1, the game is opened in portrait mode.
Is there any way that I can rotate the cocos2D game into landscape mode in the iPhone 5 running iOS 6.1.
Some extra notes:
The game is being pushed from a view controller in my test app.
Since I am pushing the game from an iOS app, I have to support portrait mode in the "Support Interface Orientations" section. (If I was just doing the game, I would just easily set the Support Interface Orientation to landscape left/landscape right)
I have also tried different methods such as for iOS 6 such as:
-(NSUInteger)supportedInterfaceOrientations
-(UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
-(BOOL)shouldAutorotate
But it has given me different results when I tried those methods.
Ideally, I would like the app to be locked in the Portrait mode and game to be locked into Landscape mode.
So, I'm wondering if it is possible to have an app that remains locked in the portrait mode and the game locked in landscape mode (for both iOS 5 & iOS 6) when opened?
Here's a link to a sample project I was working on:
http://www.4shared.com/zip/yEAA1D_N/MyNinjaGame.html
I just set the orientation modes in Xcode ("Summary" tab on your target) to landscape left and right. Then for every UIViewController I added this:
// Autorotation iOS5 + iOS6
- (BOOL)shouldAutorotateToInterfaceOrientation: (UIInterfaceOrientation)toInterfaceOrientation {
return UIInterfaceOrientationIsLandscape(toInterfaceOrientation);
}
What I'm doing for landscape in my cocos2d game (on iOS 6.1):
//This is in the AppDelegate.m
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return UIInterfaceOrientationIsLandscape(interfaceOrientation);
//change to 'return UIInterfaceOrientationIsPortrait(interfaceOrientation);' for portrait
}

What are the changes in ios 6 as compare to previous versions of xcode?

I was build an app in ios 4.1 but now i am using ios 6 to build it but there are problems in pushviewcontroller and orientation methods. So can any one tell me what are the changes have brought in ios 6?
I think that best solution is to stick to official apple documentation. So according to that I use following methods and everything is working very well on iOS 5 and 6. In all of your ViewControllers override following methods.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
// Return YES for supported orientations
return UIInterfaceOrientationIsPortrait(interfaceOrientation);
}
Methods for iOS 6, first method returns supported orientation mask (as their name indicate), you can change it into Landscape or what suites you best.
-(NSInteger)supportedInterfaceOrientations{
return UIInterfaceOrientationMaskPortrait; //UIInterfaceOrientationMaskPortrait or LandscapeLeft ...
}
second one thats tells your VC which is preferred interface orientation when VC is going to be displayed.
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
return UIInterfaceOrientationPortrait; //tells your VC in which orientation it should be presented, if you set Porttrait it would be in Portrait or otherwise ...
}
This solution is working

How to enable "AutoLayout" of iOS 6 programmatically?

How can I enable "AutoLayout" programmatically. Actually I have to create an app which should run on iOS6 and iOS5 but we can enable "AutoLayout" in the XIB in iOS 6 only and it will not work on the iOS 5 so I am checking the iOS version and using if else condition for the appropriate task according to the iOS. So if app would be running on iOS 6, I will enable the AutoLayout otherwise I will write the code for AutoResizing. Please let me know if I am unclear at any point.
If you want autolayout on iOS6 devices but not iOS5 (unuspported) but still want to use nib's, you have to keep separate nibs. One for iOS5 and one for iOS6.
When loading your nib, check if autolayout is supported by checking if the NSLayoutConstraint class exists:
if (NSClassFromString(#"NSLayoutConstraint"))
//Load iOS6 nib with autlayout.
else
//Load iOS5 nib sans autolayout.

Event touch up inside work in iphone but dont work in ipad ios6

This generate the error
Generate a project for iphone only with orientation landscape left and landscape right
Add a button to the interface builder
Run on the ipad simulator
Press the button and it does not work.
What can i do?
This solved the problem for orientations in ios 6
-(NSUInteger)supportedInterfaceOrientations{
return UIInterfaceOrientationMaskLandscapeLeft | UIInterfaceOrientationMaskLandscapeRight;
}
Implementing the supportedInterfaceOrientations method in the ViewController does not help.
Kind of workaround would be to chose "Universal" (iPhone + iPad) as target device.