0

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

 -(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];

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

我非常肯定这是由于以下原因:

frame.origin.y = 420;

由于 iPhone 屏幕是 420。任何人都可以帮我输入正确的数字吗?

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

4

1 回答 1

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 来使用它,但这取决于您并且没有必要。

于 2012-05-12T02:26:48.243 回答