Reading this http://www.cocos2d-iphone.org/forum/topic/33326
I guess Cocos2d-x also should do the fix in AppController.mm at line 44:
// set the Navigation Controller as the root view controller for iOS4,5,6 [window setRootViewController: viewController];
unlink
September 10, 2012, 1:25pm
#2
Thank you it worked really well. It was quite an annoying issue since I upgraded all my iOS devices to iOS 6 recently.
On Landscape this would mess up the screen coords for the first frames.
http://www.cocos2d-iphone.org/forum/topic/37742
Maybe not in Cocos2d-x?
Eneli
September 13, 2012, 4:05am
#4
On top of using window setRootViewController, I was able to make the screen draw correctly in iOS 6 (in landscape) by adding this to RootViewController.mm
-(NSUInteger)supportedInterfaceOrientations{
return UIInterfaceOrientationMaskLandscape;
}
- (BOOL)shouldAutorotate {
return YES;
}
Alex Swan wrote:
On top of using window setRootViewController, I was able to make the screen draw correctly adding this to RootViewController.mm
>
[…]
That’s for a landscape game, I guess and iOS6 SDK only right?
Just encountered this myself. Great fix, thanks for sharing.
Ben
Can someone post what happens when you compile with iOS 5.1 SDK and run it on iOS6?
Hey Alex Swan… This is an AMAZING fix… You might want to tell riq or someone on the cocos2d ios boards.
I was sweating bullets… I had just finished my game, and I could not get it to orient correctly for Ios6….
Dude, that is a LIFESAVER.
You might want to see about posting that on Git Hub.
Thank you Sooo Much
Hey Alex Swan… This is an AMAZING fix… You might want to tell riq or someone on the cocos2d ios boards.
I was sweating bullets… I had just finished my game, and I could not get it to orient correctly for Ios6….
Dude, that is a LIFESAVER.
You might want to see about posting that on Git Hub.
Thank you Sooo Much
Eneli
September 14, 2012, 12:53am
#10
I was making my game landscape.
After making my fixes for iOS 6, it wasn’t drawing in iOS 5 correctly. This fix from elsewhere worked:
NSString *reqSysVer = @"6.0";
NSString *currSysVer = [[UIDevice currentDevice] systemVersion];
if ([currSysVer compare:reqSysVer options:NSNumericSearch] != NSOrderedAscending)
{
[window setRootViewController:viewController]; //iOS 6
} else {
[window addSubview: viewController.view]; //iOS 5 or less
}
`AlexSwan
Why not just :
if ([window respondsToSelector:`selector(setRootViewController:)]) {
//iOS >=4.0
window.rootViewController = viewController;
} else {
//iOS <4.0
[window addSubview:viewController.view];
}
Posted a issue on Github already.
opened 02:51PM - 14 Sep 12 UTC
closed 03:23PM - 24 Sep 12 UTC
Can't talk about iOS6 features because of NDA, but this fix should be considered :-)
iOS/AppController.mm at line 44:
// set the Navigation...
Eneli
September 14, 2012, 5:39pm
#12
@Herman Jakobi
That does compile, but the problem I’ve noticed is [window setRootViewController:viewController] works for iOS 5, but it puts my game in portrait mode, which is incorrect.
I agree that your method is best practice and that mine is more of a workaround, though.
Talk about karma! Thats MY fix — coupled with yours is what worked. I posted that on the iOS cocos2d board yesterday….
Pretty cool… Anyway, good luck
NSString reqSysVer = @“6.0”;
NSString currSysVer = [[UIDevice currentDevice] systemVersion];
if ([currSysVer compare:reqSysVer options:NSNumericSearch] != NSOrderedAscending)
{
[window setRootViewController:viewController]; //iOS 6
} else {
[window addSubview: viewController.view]; //iOS 5 or less
}
Talk about karma! Thats MY fix — coupled with yours is what worked. I posted that on the iOS cocos2d board yesterday….
Pretty cool… Anyway, good luck
NSString reqSysVer = @“6.0”;
NSString currSysVer = [[UIDevice currentDevice] systemVersion];
if ([currSysVer compare:reqSysVer options:NSNumericSearch] != NSOrderedAscending)
{
[window setRootViewController:viewController]; //iOS 6
} else {
[window addSubview: viewController.view]; //iOS 5 or less
}
@Alex Swan That code works for Cocos2d landscape with iOS 5.1 SDK and using iOS5. So you mean that code even puts your app in portrait using Cocos2d-x under iOS5 (or iOS6 ?) ? Compiled with what iOS SDK version?
Guys just downloaded xcode 4.5, and upgraded my ipad…
This code isnt working for ipad retina with ios6,
someone has a position on how to solve this with the released version, for all devices???
Eneli
September 21, 2012, 7:02pm
#17
It works for me, xcode 4.5, ipad 3 w/iOS 6.0. You are kind of vague on the reason it isn’t working for you.
I did this chunk of code on AppController.mm
(BOOL)application:(UIApplication )application didFinishLaunchingWithOptions:launchOptions {
// Override point for customization after application launch.
// Add the view controller’s view to the window and display.
window = initWithFrame: bounds]];
EAGLView *glView =
pixelFormat: kEAGLColorFormatRGBA8
depthFormat: GL_DEPTH_COMPONENT16
preserveBackbuffer: NO
sharegroup: nil
multiSampling: NO
numberOfSamples: 0 ];
// Use RootViewController manage EAGLView
viewController = initWithNibName:nil bundle:nil];
viewController.wantsFullScreenLayout = YES;
viewController.view =*glView;
// Set RootViewController to window
NSString reqSysVer = @“6.0”;
NSString currSysVer = [[UIDevice currentDevice] systemVersion];
if ([currSysVer compare:reqSysVer options:NSNumericSearch] != NSOrderedAscending)
{
[window setRootViewController:viewController]; //iOS 6
} else
{
[window addSubview: viewController.view]; //iOS 5 or less
}
[window makeKeyAndVisible];
__glView.multipleTouchEnabled = YES;
[[UIApplication sharedApplication] setStatusBarHidden: YES];
cocos2d::CCApplication::sharedApplication()~~>run;
return YES;
}
and this chunk of code on RootViewController:
~~(NSUInteger)supportedInterfaceOrientations{
return UIInterfaceOrientationMaskLandscape;
}
(BOOL)shouldAutorotate {
return YES;
}
and the result is in the image attached
Eneli
September 21, 2012, 8:54pm
#19
Ok, I’ve recreated the issue you’re having with the latest code from github. I’m not able to fix it.
I do know that this code works with the latest stable version (August 30 2012): http://cocos2d-x.googlecode.com/files/cocos2d-2.0-x-2.0.2.zip
thanks Sergio. worked like a charm.