2012-09-24 5 views
3

iOS 6의 앱 방향에 문제가 있습니다. "가로 (오른쪽 홈 버튼)"및 "가로 (왼쪽 홈 버튼)"로 설정되어 있어도 " 세로 "응용 프로그램 왜곡.iOS6의 방향 문제

나는 RootViewController.m과 함께 작업하려했지만 행운은 없었습니다!

다음은 코드입니다. 누군가 나를 도울 수 있습니까?

@implementation RootViewController 

    /* 
    // The designated initializer. Override if you create the controller programmatically and want to perform customization that is not appropriate for viewDidLoad. 
    - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil { 
if ((self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil])) { 
// Custom initialization 
} 
return self; 
    } 
    */ 

    /* 
    // Implement loadView to create a view hierarchy programmatically, without using a nib. 
    - (void)loadView { 
    } 
    */ 


    // Implement viewDidLoad to do additional setup after loading the view, typically from a nib. 
    - (void)viewDidLoad { 
[super viewDidLoad]; 
    } 



    // Override to allow orientations other than the default portrait orientation. 
    - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { 

// 
// There are 2 ways to support auto-rotation: 
// - The OpenGL/cocos2d way 
//  - Faster, but doesn't rotate the UIKit objects 
// - The ViewController way 
// - A bit slower, but the UiKit objects are placed in the right place 
// 

    #if GAME_AUTOROTATION==kGameAutorotationNone 
// 
// EAGLView won't be autorotated. 
// Since this method should return YES in at least 1 orientation, 
// we return YES only in the Portrait orientation 
// 
return (interfaceOrientation == UIInterfaceOrientationPortrait); 

    #elif GAME_AUTOROTATION==kGameAutorotationCCDirector 
// 
// EAGLView will be rotated by cocos2d 
// 
// Sample: Autorotate only in landscape mode 
// 
if(interfaceOrientation == UIInterfaceOrientationLandscapeLeft) { 
    [[CCDirector sharedDirector] setDeviceOrientation: kCCDeviceOrientationLandscapeRight]; 
} else if(interfaceOrientation == UIInterfaceOrientationLandscapeRight) { 
    [[CCDirector sharedDirector] setDeviceOrientation: kCCDeviceOrientationLandscapeLeft]; 
} 

// Since this method should return YES in at least 1 orientation, 
// we return YES only in the Portrait orientation 
return (interfaceOrientation == UIInterfaceOrientationPortrait); 

    #elif GAME_AUTOROTATION == kGameAutorotationUIViewController 
// 
// EAGLView will be rotated by the UIViewController 
// 
// Sample: Autorotate only in landscpe mode 
// 
// return YES for the supported orientations 

return (UIInterfaceOrientationIsLandscape(interfaceOrientation)); 

    #else 
    #error Unknown value in GAME_AUTOROTATION 

    #endif // GAME_AUTOROTATION 


// Shold not happen 
return NO; 
    } 

    // 
    // This callback only will be called when GAME_AUTOROTATION == kGameAutorotationUIViewController 
    // 
    #if GAME_AUTOROTATION == kGameAutorotationUIViewController 
    -(void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration 
    { 
// 
// Assuming that the main window has the size of the screen 
// BUG: This won't work if the EAGLView is not fullscreen 
/// 
CGRect screenRect = [[UIScreen mainScreen] bounds]; 
CGRect rect = CGRectZero; 


if(toInterfaceOrientation == UIInterfaceOrientationPortrait || toInterfaceOrientation == UIInterfaceOrientationPortraitUpsideDown)  
    rect = screenRect; 

else if(toInterfaceOrientation == UIInterfaceOrientationLandscapeLeft || toInterfaceOrientation == UIInterfaceOrientationLandscapeRight) 
    rect.size = CGSizeMake(screenRect.size.height, screenRect.size.width); 

CCDirector *director = [CCDirector sharedDirector]; 
EAGLView *glView = [director openGLView]; 
float contentScaleFactor = [director contentScaleFactor]; 

if(contentScaleFactor != 1) { 
    rect.size.width *= contentScaleFactor; 
    rect.size.height *= contentScaleFactor; 
} 
glView.frame = rect; 
    } 
    #endif // GAME_AUTOROTATION == kGameAutorotationUIViewController 


    - (void)didReceiveMemoryWarning { 
    // Releases the view if it doesn't have a superview. 
[super didReceiveMemoryWarning]; 

    // Release any cached data, images, etc that aren't in use. 
    } 

    - (void)viewDidUnload { 
[super viewDidUnload]; 
// Release any retained subviews of the main view. 
// e.g. self.myOutlet = nil; 
    } 


- (void)dealloc { 
[super dealloc]; 
} 



@end 

제발 도와주세요! 감사!

답변

1

shouldAutorotateToInterfaceOrientation은 iOS 6에서 사용되지 않습니다. UIViewController documentation의 맨 위에있는 '보기 순환 게재'를 참조하십시오. 더 이상 작업하지 않으면 프로젝트 설정에서 지정한 모든 것을 얻을 수 있습니다.

에서 iOS 5에서

및 이전 버전은, 당신이있어 :

return (interfaceOrientation == UIInterfaceOrientationPortrait); 

그래서 그 시스템에 명시 적으로 세로 방향이 뷰 컨트롤러를 제한하고 있습니다.

0

AppDelegate.mm 파일에서이를 확인해야합니다. 다음 코드 줄이 존재하는지 확인하십시오.

// Supported orientations: Landscape. Customize it for your own needs 
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation 
{ 
    return UIInterfaceOrientationIsLandscape(interfaceOrientation); 
} 
+0

존재하지 않으며 방금 추가했지만 여전히 동일한 문제가 발생합니다. – esierr1