Cocos2d-x iOS7 Presenting view controllers on detached view controllers is discouraged

Presenting view controllers on detached view controllers is discouraged <UIViewController: 0xc808560>.

 전에 정리했던 Cocos2d-x iOS Game Center 연동 샘플소스를 그대로 사용했더니 iOS7에서 위와 같은 로그와 함께 이후 뷰로 터치등이 먹통이 되는 증상이 발생했습니다. 단순히 아래와 같이 게임 센터 로그인 창에서 로그인을 안하고 Cancel 후



 아래와 같이 showLeaderboard 기능을 하는 Close 버튼을 클릭해 리더보드를 한 번 호출하고 OK를 눌러 게임으로 돌아가는 순간부터 먹통이 되더군요.



// Display another view controller as a modal child. Uses a vertical sheet transition if animated.This method has been replaced by presentViewController:animated:completion:
- (void)presentModalViewController:(UIViewController *)modalViewController animated:(BOOL)animated NS_DEPRECATED_IOS(2_0, 6_0);

 iOS SDK에 위와 같이 있길래 아래와 같이 presentViewController로 해줬지만 해결되지 않았습니다.


//[tempUIView presentModalViewController:pController animated:YES];
[tempUIView presentViewController:pController animated:YES completion:nil];

 혹시나 해서 예전에 정리했던 RootViewController을 가져오기 해서 아래와 같이 했더니 잘 작동하네요.

// 루트뷰에 하므로 불필요
//UIViewController* tempUIView;
+ (void) showLeaderboard
{
    GKLeaderboardViewController* pController = [[[GKLeaderboardViewController alloc] init] autorelease];
    
    if( pController != nil )
    {
        pController.leaderboardDelegate = self;
        
        /* 기존 튜토리얼 소스
        tempUIView = [[UIViewController alloc] init];
        [[[EAGLView sharedEGLView] window] addSubview:tempUIView.view];
        [tempUIView presentModalViewController:pController animated:YES];
         */
        // 루트뷰를 얻어와서 처리
        UIViewController* pRootViewController = (UIViewController*)[[[[[EAGLView sharedEGLView] window] subviews]objectAtIndex:0] nextResponder];
        
        [pRootViewController presentModalViewController:pController animated:YES];
        // 이것도 가능
        //[pRootViewController presentViewController:pController animated:YES completion:nil];
        
    }
}

+ (void) leaderboardViewControllerDidFinish:(GKLeaderboardViewController *)viewController
{
    [viewController dismissModalViewControllerAnimated:YES];
    // presentViewController  했다면...
    //[viewController dismissViewControllerAnimated:YES completion:nil];
    [viewController.view.superview removeFromSuperview];
    //[tempUIView release];

}

댓글

이 블로그의 인기 게시물

'xxx.exe' 프로그램을 시작할 수 없습니다. 지정된 파일을 찾을 수 없습니다.

goorm IDE에서 node.js 프로젝트로 Hello World Simple Server 만들어 띄워보기

애드센스 수익을 웨스턴 유니온으로 수표대신 현금으로 지급 받아보자.