我正在制作和应用程序并遇到此代码错误:
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];
}
所以我面临的问题是:
- 这些按钮不适用于警报,它们根本不做任何事情。
- 存在错误“一元表达式的参数类型“无效”无效”
我该如何解决这个问题?