From 889b0e05815b199d82915e2b094fb6af91d7586b Mon Sep 17 00:00:00 2001 From: Magician Date: Sat, 16 Aug 2014 01:59:54 +0200 Subject: [PATCH] Forwards CCNavigationController's device orientation methods to the AppDelegate. Gives an option for different behaviors than default --- cocos2d/CCProtocols.h | 1 + cocos2d/Platforms/iOS/CCAppDelegate.m | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/cocos2d/CCProtocols.h b/cocos2d/CCProtocols.h index c53b33fa4ac..a73f2ecd96e 100644 --- a/cocos2d/CCProtocols.h +++ b/cocos2d/CCProtocols.h @@ -133,6 +133,7 @@ -(GLKMatrix4) updateProjection; #ifdef __CC_PLATFORM_IOS +-(NSUInteger)supportedInterfaceOrientations; /** Returns a Boolean value indicating whether the CCDirector supports the specified orientation. Default value is YES (supports all possible orientations) */ - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation; diff --git a/cocos2d/Platforms/iOS/CCAppDelegate.m b/cocos2d/Platforms/iOS/CCAppDelegate.m index 8b48a31d1c8..73992cf3b9d 100644 --- a/cocos2d/Platforms/iOS/CCAppDelegate.m +++ b/cocos2d/Platforms/iOS/CCAppDelegate.m @@ -76,6 +76,9 @@ @implementation CCNavigationController // Only valid for iOS 6+. NOT VALID for iOS 4 / 5. -(NSUInteger)supportedInterfaceOrientations { + if ([_appDelegate respondsToSelector:_cmd]) + return (NSUInteger)[_appDelegate supportedInterfaceOrientations]; + if ([_screenOrientation isEqual:CCScreenOrientationAll]) { return UIInterfaceOrientationMaskAll; @@ -94,6 +97,9 @@ -(NSUInteger)supportedInterfaceOrientations // Only valid on iOS 4 / 5. NOT VALID for iOS 6. - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { + if ([_appDelegate respondsToSelector:_cmd]) + return (BOOL)[_appDelegate shouldAutorotateToInterfaceOrientation:interfaceOrientation]; + if ([_screenOrientation isEqual:CCScreenOrientationAll]) { return YES;