From c9772c76ec7a95daefee9ba240a1a24e22388ba0 Mon Sep 17 00:00:00 2001 From: walzer Date: Thu, 27 Sep 2012 00:44:40 +0800 Subject: [PATCH 1/3] fix compilation error in xcodebuild command line, which are caused by ios6 deprecated marcos and enums --- cocos2dx/platform/ios/FontLabel/FontLabel.m | 13 ++++++------- .../platform/ios/FontLabel/FontLabelStringDrawing.m | 13 ++++++------- samples/HelloCpp/proj.ios/RootViewController.mm | 10 ++++++++-- samples/HelloLua/proj.ios/RootViewController.mm | 2 ++ samples/SimpleGame/proj.ios/RootViewController.mm | 2 ++ .../TestCpp/proj.ios/Classes/RootViewController.mm | 2 ++ .../TestJavascript/proj.ios/RootViewController.mm | 2 ++ samples/TestLua/proj.ios/RootViewController.mm | 2 ++ 8 files changed, 30 insertions(+), 16 deletions(-) diff --git a/cocos2dx/platform/ios/FontLabel/FontLabel.m b/cocos2dx/platform/ios/FontLabel/FontLabel.m index 1e97d650d9..3e60ad6b78 100644 --- a/cocos2dx/platform/ios/FontLabel/FontLabel.m +++ b/cocos2dx/platform/ios/FontLabel/FontLabel.m @@ -118,18 +118,17 @@ } size.width = MIN(size.width, origSize.width); // adjust the point for alignment - switch ((NSTextAlignment)self.textAlignment) { - case NSTextAlignmentLeft: + switch (self.textAlignment) { + case UITextAlignmentLeft: break; - case NSTextAlignmentCenter: + case UITextAlignmentCenter: point.x += (origSize.width - size.width) / 2.0f; break; - case NSTextAlignmentRight: + case UITextAlignmentRight: point.x += origSize.width - size.width; break; - case NSTextAlignmentJustified: - case NSTextAlignmentNatural: - default: break; + default: + break; } [self.text drawAtPoint:point forWidth:size.width withZFont:actualFont lineBreakMode:self.lineBreakMode]; } else { diff --git a/cocos2dx/platform/ios/FontLabel/FontLabelStringDrawing.m b/cocos2dx/platform/ios/FontLabel/FontLabelStringDrawing.m index bad5abd028..f7fcbf1a72 100644 --- a/cocos2dx/platform/ios/FontLabel/FontLabelStringDrawing.m +++ b/cocos2dx/platform/ios/FontLabel/FontLabelStringDrawing.m @@ -637,19 +637,18 @@ static CGSize drawOrSizeTextConstrainedToSize(BOOL performDraw, NSString *string // draw if (performDraw) { - switch ((NSTextAlignment)alignment) { - case NSTextAlignmentLeft: + switch (alignment) { + case UITextAlignmentLeft: drawPoint.x = 0; break; - case NSTextAlignmentCenter: + case UITextAlignmentCenter: drawPoint.x = (constrainedSize.width - lineSize.width) / 2.0f; break; - case NSTextAlignmentRight: + case UITextAlignmentRight: drawPoint.x = constrainedSize.width - lineSize.width; break; - case NSTextAlignmentJustified: - case NSTextAlignmentNatural: - default: break; + default: + break; } NSUInteger stopGlyphIdx = glyphIdx; NSUInteger lastRunIdx = currentRunIdx; diff --git a/samples/HelloCpp/proj.ios/RootViewController.mm b/samples/HelloCpp/proj.ios/RootViewController.mm index fee0d0c071..d7022bfbeb 100644 --- a/samples/HelloCpp/proj.ios/RootViewController.mm +++ b/samples/HelloCpp/proj.ios/RootViewController.mm @@ -57,15 +57,21 @@ return UIInterfaceOrientationIsLandscape( interfaceOrientation ); } -// For ios6, use supportedInterfaceOrientations & shouldAutorotate instead -- (NSUInteger) supportedInterfaceOrientations{ +// For ios6.0 and higher, use supportedInterfaceOrientations & shouldAutorotate instead +- (NSUInteger) supportedInterfaceOrientations +{ +#ifdef __IPHONE_6_0 return UIInterfaceOrientationMaskLandscape; +#endif } - (BOOL) shouldAutorotate { return YES; } + + + - (void)didReceiveMemoryWarning { // Releases the view if it doesn't have a superview. [super didReceiveMemoryWarning]; diff --git a/samples/HelloLua/proj.ios/RootViewController.mm b/samples/HelloLua/proj.ios/RootViewController.mm index fee0d0c071..b9a0382ab3 100644 --- a/samples/HelloLua/proj.ios/RootViewController.mm +++ b/samples/HelloLua/proj.ios/RootViewController.mm @@ -59,7 +59,9 @@ // For ios6, use supportedInterfaceOrientations & shouldAutorotate instead - (NSUInteger) supportedInterfaceOrientations{ +#ifdef __IPHONE_6_0 return UIInterfaceOrientationMaskLandscape; +#endif } - (BOOL) shouldAutorotate { diff --git a/samples/SimpleGame/proj.ios/RootViewController.mm b/samples/SimpleGame/proj.ios/RootViewController.mm index fee0d0c071..b9a0382ab3 100644 --- a/samples/SimpleGame/proj.ios/RootViewController.mm +++ b/samples/SimpleGame/proj.ios/RootViewController.mm @@ -59,7 +59,9 @@ // For ios6, use supportedInterfaceOrientations & shouldAutorotate instead - (NSUInteger) supportedInterfaceOrientations{ +#ifdef __IPHONE_6_0 return UIInterfaceOrientationMaskLandscape; +#endif } - (BOOL) shouldAutorotate { diff --git a/samples/TestCpp/proj.ios/Classes/RootViewController.mm b/samples/TestCpp/proj.ios/Classes/RootViewController.mm index 7e47e134a8..5fe93273dd 100644 --- a/samples/TestCpp/proj.ios/Classes/RootViewController.mm +++ b/samples/TestCpp/proj.ios/Classes/RootViewController.mm @@ -42,7 +42,9 @@ // For ios6, use supportedInterfaceOrientations & shouldAutorotate instead - (NSUInteger) supportedInterfaceOrientations{ +#ifdef __IPHONE_6_0 return UIInterfaceOrientationMaskLandscape; +#endif } - (BOOL) shouldAutorotate { diff --git a/samples/TestJavascript/proj.ios/RootViewController.mm b/samples/TestJavascript/proj.ios/RootViewController.mm index 39200bd7c3..9c435babc3 100644 --- a/samples/TestJavascript/proj.ios/RootViewController.mm +++ b/samples/TestJavascript/proj.ios/RootViewController.mm @@ -42,7 +42,9 @@ // For ios6, use supportedInterfaceOrientations & shouldAutorotate instead - (NSUInteger) supportedInterfaceOrientations{ +#ifdef __IPHONE_6_0 return UIInterfaceOrientationMaskLandscape; +#endif } - (BOOL) shouldAutorotate { diff --git a/samples/TestLua/proj.ios/RootViewController.mm b/samples/TestLua/proj.ios/RootViewController.mm index fee0d0c071..b9a0382ab3 100644 --- a/samples/TestLua/proj.ios/RootViewController.mm +++ b/samples/TestLua/proj.ios/RootViewController.mm @@ -59,7 +59,9 @@ // For ios6, use supportedInterfaceOrientations & shouldAutorotate instead - (NSUInteger) supportedInterfaceOrientations{ +#ifdef __IPHONE_6_0 return UIInterfaceOrientationMaskLandscape; +#endif } - (BOOL) shouldAutorotate { From edaf22f14dfad2bf0c31cb686a50ba7fc0dc6b8b Mon Sep 17 00:00:00 2001 From: walzer Date: Thu, 27 Sep 2012 00:46:09 +0800 Subject: [PATCH 2/3] fix xcode4 templates compilation error for xcodebuild command line mode, caused by ios6 compatibility. --- template/xcode4/base_ios.xctemplate/ios/RootViewController.mm | 2 ++ 1 file changed, 2 insertions(+) diff --git a/template/xcode4/base_ios.xctemplate/ios/RootViewController.mm b/template/xcode4/base_ios.xctemplate/ios/RootViewController.mm index 7ca84275ca..ae0bf611c2 100644 --- a/template/xcode4/base_ios.xctemplate/ios/RootViewController.mm +++ b/template/xcode4/base_ios.xctemplate/ios/RootViewController.mm @@ -42,7 +42,9 @@ // For ios6, use supportedInterfaceOrientations & shouldAutorotate instead - (NSUInteger) supportedInterfaceOrientations{ +#ifdef __IPHONE_6_0 return UIInterfaceOrientationMaskLandscape; +#endif } - (BOOL) shouldAutorotate { From d18eecf2472274e110ebeacf47e2465b50edb52c Mon Sep 17 00:00:00 2001 From: walzer Date: Thu, 27 Sep 2012 10:28:00 +0800 Subject: [PATCH 3/3] UIInterfaceOrientationMaskLandscape -> UIInterfaceOrientationMaskAllButUpsideDown, developers still need to set orientation in xcode->targets --- samples/HelloCpp/proj.ios/RootViewController.mm | 2 +- samples/HelloLua/proj.ios/RootViewController.mm | 2 +- samples/SimpleGame/proj.ios/RootViewController.mm | 2 +- samples/TestCpp/proj.ios/Classes/RootViewController.mm | 2 +- samples/TestJavascript/proj.ios/RootViewController.mm | 2 +- samples/TestLua/proj.ios/RootViewController.mm | 2 +- template/xcode4/base_ios.xctemplate/ios/RootViewController.mm | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/samples/HelloCpp/proj.ios/RootViewController.mm b/samples/HelloCpp/proj.ios/RootViewController.mm index d7022bfbeb..7376e21c9a 100644 --- a/samples/HelloCpp/proj.ios/RootViewController.mm +++ b/samples/HelloCpp/proj.ios/RootViewController.mm @@ -61,7 +61,7 @@ - (NSUInteger) supportedInterfaceOrientations { #ifdef __IPHONE_6_0 - return UIInterfaceOrientationMaskLandscape; + return UIInterfaceOrientationMaskAllButUpsideDown; #endif } diff --git a/samples/HelloLua/proj.ios/RootViewController.mm b/samples/HelloLua/proj.ios/RootViewController.mm index b9a0382ab3..cccdbab91e 100644 --- a/samples/HelloLua/proj.ios/RootViewController.mm +++ b/samples/HelloLua/proj.ios/RootViewController.mm @@ -60,7 +60,7 @@ // For ios6, use supportedInterfaceOrientations & shouldAutorotate instead - (NSUInteger) supportedInterfaceOrientations{ #ifdef __IPHONE_6_0 - return UIInterfaceOrientationMaskLandscape; + return UIInterfaceOrientationMaskAllButUpsideDown; #endif } diff --git a/samples/SimpleGame/proj.ios/RootViewController.mm b/samples/SimpleGame/proj.ios/RootViewController.mm index b9a0382ab3..cccdbab91e 100644 --- a/samples/SimpleGame/proj.ios/RootViewController.mm +++ b/samples/SimpleGame/proj.ios/RootViewController.mm @@ -60,7 +60,7 @@ // For ios6, use supportedInterfaceOrientations & shouldAutorotate instead - (NSUInteger) supportedInterfaceOrientations{ #ifdef __IPHONE_6_0 - return UIInterfaceOrientationMaskLandscape; + return UIInterfaceOrientationMaskAllButUpsideDown; #endif } diff --git a/samples/TestCpp/proj.ios/Classes/RootViewController.mm b/samples/TestCpp/proj.ios/Classes/RootViewController.mm index 5fe93273dd..db521bb0ce 100644 --- a/samples/TestCpp/proj.ios/Classes/RootViewController.mm +++ b/samples/TestCpp/proj.ios/Classes/RootViewController.mm @@ -43,7 +43,7 @@ // For ios6, use supportedInterfaceOrientations & shouldAutorotate instead - (NSUInteger) supportedInterfaceOrientations{ #ifdef __IPHONE_6_0 - return UIInterfaceOrientationMaskLandscape; + return UIInterfaceOrientationMaskAllButUpsideDown; #endif } diff --git a/samples/TestJavascript/proj.ios/RootViewController.mm b/samples/TestJavascript/proj.ios/RootViewController.mm index 9c435babc3..7a0d59ccc9 100644 --- a/samples/TestJavascript/proj.ios/RootViewController.mm +++ b/samples/TestJavascript/proj.ios/RootViewController.mm @@ -43,7 +43,7 @@ // For ios6, use supportedInterfaceOrientations & shouldAutorotate instead - (NSUInteger) supportedInterfaceOrientations{ #ifdef __IPHONE_6_0 - return UIInterfaceOrientationMaskLandscape; + return UIInterfaceOrientationMaskAllButUpsideDown; #endif } diff --git a/samples/TestLua/proj.ios/RootViewController.mm b/samples/TestLua/proj.ios/RootViewController.mm index b9a0382ab3..cccdbab91e 100644 --- a/samples/TestLua/proj.ios/RootViewController.mm +++ b/samples/TestLua/proj.ios/RootViewController.mm @@ -60,7 +60,7 @@ // For ios6, use supportedInterfaceOrientations & shouldAutorotate instead - (NSUInteger) supportedInterfaceOrientations{ #ifdef __IPHONE_6_0 - return UIInterfaceOrientationMaskLandscape; + return UIInterfaceOrientationMaskAllButUpsideDown; #endif } diff --git a/template/xcode4/base_ios.xctemplate/ios/RootViewController.mm b/template/xcode4/base_ios.xctemplate/ios/RootViewController.mm index ae0bf611c2..4c6f6f9224 100644 --- a/template/xcode4/base_ios.xctemplate/ios/RootViewController.mm +++ b/template/xcode4/base_ios.xctemplate/ios/RootViewController.mm @@ -43,7 +43,7 @@ // For ios6, use supportedInterfaceOrientations & shouldAutorotate instead - (NSUInteger) supportedInterfaceOrientations{ #ifdef __IPHONE_6_0 - return UIInterfaceOrientationMaskLandscape; + return UIInterfaceOrientationMaskAllButUpsideDown; #endif }