0

我正在制作和应用程序并遇到此代码错误:

NSString *timemessage = [NSString stringWithFormat:@"Unlucky! You survived for %i seconds!", timenumber];
UIAlertView *alert1 = [[UIAlertView alloc] initWithTitle:@"You've Been Caught!" message:timemessage delegate:nil cancelButtonTitle:@"Try Again" otherButtonTitles:@"Show Leaderboard", @"Submit To Game Center",nil];
[alert1 show];

-(void) alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)ButtonIndex {
    NSString *buttonTitle = [alertView buttonTitleAtIndex:ButtonIndex];
    if ([buttonTitle isEqualToString:@"Submit To Game Center"]) {
        - (void) reportScore: (int64_t) score forCategory: (NSString*) category
        {
            GKScore *scoreReporter = [[[GKScore alloc] initWithCategory:@"*****"] autorelease];
            scoreReporter.value = score;
            [scoreReporter reportScoreWithCompletionHandler:^(NSError *error) {
                if (error != nil)
                {
                    // handle the reporting error
                }
            }];
        }
    }
    else if ([buttonTitle isEqualToString:@"Show Leaderboard"]){
        - (void) showLeaderboard:
        {
            GKLeaderboardViewController *leaderboardController = [[GKLeaderboardViewController alloc] init];
            if (leaderboardController != nil)
            {
                leaderboardController.leaderboardDelegate = self;
                [self presentModalViewController: leaderboardController animated: YES];
            }
        }
    }
}
-(void) leaderboardViewControllerDidFinish:(GKLeaderboardViewController *)viewController{
    [self dismissModalViewControllerAnimated:YES];
} 

所以我面临的问题是:

  1. 这些按钮不适用于警报,它们根本不做任何事情。
  2. 存在错误“一元表达式的参数类型“无效”无效”

我该如何解决这个问题?

4

1 回答 1

0

我确信第一个问题是关于警报代表的。

UIAlertView *alert1 = [[UIAlertView alloc] initWithTitle:@"You've Been Caught!" message:timemessage delegate:self cancelButtonTitle:@"Try Again" otherButtonTitles:@"Show Leaderboard", @"Submit To Game Center",nil];
[alert1 show];

代表:自己

于 2012-08-22T01:29:44.543 回答