iPAD游戏中心视图(灰色屏幕)

时间:2012-05-11 01:01:56

标签: xcode view leaderboard

我使用此代码显示排行榜:

 -(void)viewscores:(SPEvent*)event

   {
     tempVC = [[UIViewController alloc] init];


    GKLeaderboardViewController* leaderboardController = [[[GKLeaderboardViewController alloc] init] autorelease];
    if (leaderboardController != nil)
    {
        leaderboardController.leaderboardDelegate = self;
        UIView *sparrowView = self.stage.nativeView; // take care that self.stage != nil!
        [sparrowView addSubview:tempVC.view];
        //[tempVC.view addSubview:leaderboardController.view];
        [tempVC presentModalViewController:leaderboardController animated:YES];
    }
}

- (void)animationDidStop:(NSString*)animationID finished:(BOOL)finished context:(void *)context
{
    for(UIView *subview in [tempVC.view subviews]) {
        [subview removeFromSuperview];
    }
    [tempVC.view.superview removeFromSuperview];
    [tempVC release];
}

-(void)leaderboardViewControllerDidFinish:(GKLeaderboardViewController*)viewController
{
    CGRect frame = viewController.view.frame;
    // [tempVC dismissModalViewControllerAnimated:YES];
    [UIView beginAnimations:@"curldoup" context:nil];
    [UIView setAnimationDelegate:self];
    [UIView setAnimationDuration:.5];
    [UIView setAnimationDidStopSelector:@selector(animationDidStop:finished:context:)];
    // [UIView setAnimationTransition:UIViewAnimationTransitionCurlUp forView:self.stage.nativeView cache:YES];
    frame.origin.y = 420;
    viewController.view.frame = frame;
    [UIView commitAnimations];
    //[viewController.view removeFromSuperview];

当我在排行榜上单击DONE时,背景变为灰色,应用程序变得混乱。

我非常积极,这是由于这一行:

frame.origin.y = 420;

因为iPhone屏幕是420。 任何人都可以帮我找到正确的号码吗?

任何想法都赞赏,非常感谢!

1 个答案:

答案 0 :(得分:1)

你应该这样呈现:

- (void)showGCLeaderboard {
leaderboardController = [[GKLeaderboardViewController alloc] init];
if (leaderboardController != NULL)
{
    leaderboardController.category = kLeaderboardID; 
    leaderboardController.leaderboardDelegate = self;
    [self presentModalViewController:leaderboardController animated:YES];
}

}

所以这样做就是解雇它:

- (void)leaderboardViewControllerDidFinish:(GKLeaderboardViewController *)viewController {
    [self dismissModalViewControllerAnimated:YES];
    [viewController release];
}

由于你试图在iPad上进行此操作,你可以通过使用UIPopovers来获得它,但这取决于你并且没有必要。