We've been having trouble with this issue for a while, and just cannot find the answer to it in the docs or online searches..
Our iOS game is based on OpenGL ES, and we are implementing GameCenter turn based gaming. The following code shows a matchmaking UI for creating a turn based match. This code works fine on my iPad 1 and iPad 3. However, it will not work on my iPhone 4S!
[更新:] ビュー階層の最上位で UIWindow を使用し、サブビューとして GL ビュー/レイヤーを使用していました。これにより、新しいビューが提示されたときにわかりにくくなりました。UIView をメイン ウィンドウに追加し、GL ビューをその子として追加することで、このウィンドウを表示できるようになりました。ただし、私はまだこのビューを操作できません..
このコードは、C++ と Objective-C コードが混在する .mm ファイルからのものです。
// Configure the match making view, with our own delegate
GKTurnBasedMatchmakerViewController *mmvc =
[[GKTurnBasedMatchmakerViewController alloc]
initWithMatchRequest:request];
mmvc.showExistingMatches = YES;
// Uses our own delegate.
if(!g_pTurnBasedDelegate)
{
g_pTurnBasedDelegate = [[TurnBasedDelegate alloc] init];
}
mmvc.turnBasedMatchmakerDelegate = g_pTurnBasedDelegate;
// Get the main window's root controller and instruct it to show the match making delegate.
if(g_Env && g_Env->m_pWindow)
{
RefPtr<WindowIOS> pIOSWin = ref_static_cast<WindowIOS>(g_Env->m_pWindow);
UIWindow * pUIWin = (UIWindow *)pIOSWin->GetHandle();
UIViewController * pController = [pUIWin rootViewController];
if(pController)
{
g_pRootViewController = pController;
}
}
if(g_pRootViewController)
{
[g_pRootViewController presentViewController:mmvc animated:YES completion:nil];
}