2012-12-11 2 views
1
나는 문제가 여기에 설명 된 데

에 게임 센터를 추가 한 후 : https://devforums.apple.com/thread/165384?tstart=0 경우 화면이 세로 때문에 게임 센터 로그인 화면을로드하려고 내 응용 프로그램 충돌 및 내 응용 프로그램에만 풍경을 지원합니다. 여기 Crash on presenting UIImagePickerController under iOS 6.0 그리고 : 솔루션 작업 http://www.cocos2d-iphone.org/forum/topic/36639오류 풍경 전용적인 Cocos2D 응용 프로그램

없음 나는 위의 스레드에 설명 된 모든 솔루션뿐만 아니라 다음과 같은 스레드에서 모든 솔루션을 시도했습니다. 크래시가 여전히 발생하거나 로그인이 잘 작동하고 내 앱이 가로 및 세로 사이에서 자유롭게 회전하거나 자체를 세로로 고정하고 전체 UI를 뒤틀어 버립니다.

내가 원했던 것은 GameCenter 로그인이 세로로 작동하고, 그 다음에 앱의 다른 모든 것이 가로로 진행되는 것입니다.

다음은 내 앱에 포함 된 모든 순환 게재 메소드입니다. 이들은 appdelegate.m에 myNavigationController 구현의 것들이다 :

-(NSUInteger)supportedInterfaceOrientations { 

    // iPhone only 
    if([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) 
     return UIInterfaceOrientationMaskLandscape; 

    // iPad only 
    return UIInterfaceOrientationMaskLandscape; 
} 


- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation 
{ 
    // iPhone only 
    if([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) 
     return UIInterfaceOrientationIsLandscape(interfaceOrientation); 

    // iPad only 
    // iPhone only 
    return UIInterfaceOrientationIsLandscape(interfaceOrientation); 
} 


-(BOOL)shouldAutorotate{ 

    return NO; 
} 

그리고 appDelegate.m에서의 AppController 구현에서

는 :

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation 
{ 
    return UIInterfaceOrientationIsLandscape(interfaceOrientation); 
} 

RootViewController.m에 포함 된 :

-(BOOL)shouldAutorotate{ 
     return NO; 
} 

- (NSUInteger)supportedInterfaceOrientations 
{ 
    return UIInterfaceOrientationMaskLandscapeRight|UIInterfaceOrientationMaskLandscapeLeft; 
} 


- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation 
{ 
    return UIInterfaceOrientationLandscapeRight; 
} 


- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { 
     return NO; 
    } 


#if GAME_AUTOROTATION==kGameAutorotationNone 
    return (interfaceOrientation == UIInterfaceOrientationPortrait); 

#elif GAME_AUTOROTATION==kGameAutorotationCCDirector 
    if(interfaceOrientation == UIInterfaceOrientationLandscapeLeft) { 
     [[CCDirector sharedDirector] setDeviceOrientation: kCCDeviceOrientationLandscapeRight]; 
    } else if(interfaceOrientation == UIInterfaceOrientationLandscapeRight) { 
     [[CCDirector sharedDirector] setDeviceOrientation: kCCDeviceOrientationLandscapeLeft]; 
    } 


#elif GAME_AUTOROTATION == kGameAutorotationUIViewController 
#else 
#error Unknown value in GAME_AUTOROTATION 

#endif // GAME_AUTOROTATION 
    // Shold not happen 
    return NO; 
} 

kGameAutorotationUIViewController 

#if GAME_AUTOROTATION == kGameAutorotationUIViewController 
-(void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration 
{ 

    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]; 
    UIView *glView = [[CCDirector sharedDirector] view];; 
    float contentScaleFactor = [director contentScaleFactor]; 

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

답변

2

며칠 전에 다음 질문에 답했습니다. Cocos 2d 2.0 shouldAutorotate not working?

해당 답변에서이 기능을 사용하려면 수행해야 할 작업에 대한 지침이 있습니다. 희망이 도움이!

+0

감사합니다. 내가 그 시간 동안 일하지 않은 다른 세 개의 쓰레드에서 모든 것을 처리하기 전에 그 쓰레드를 찾았 으면 좋겠다. –