0

如何在游戏开始前添加显示指令的警报:

请参见下面的代码:

- (void)viewDidLoad
{
    [super viewDidLoad];
    if (questions && configDictionary) {

        [questionLabel setText:[[questions objectAtIndex:currentQuestonIndex] objectForKey:@"question"]];
        NSArray *answers = [[questions objectAtIndex:currentQuestonIndex] objectForKey:@"answers"];
        [answerLabel0 setText:[answers objectAtIndex:0]];
        [answerLabel1 setText:[answers objectAtIndex:1]];
        [answerLabel2 setText:[answers objectAtIndex:2]];
        [answerLabel3 setText:[answers objectAtIndex:3]];
        [pointsPerAnswerLabel setText:[NSString stringWithFormat:@"+%d points", [[configDictionary objectForKey:kPointsPerCorrectAnswer] intValue]]];
        [currentQuestionNumberLabel setText:[NSString stringWithFormat:@"question %d", currentQuestonIndex+1]];
    }
}
4

2 回答 2

0

使用UIAlertView

    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Instructions" 
    message:@"Your Instructions..." delegate:self cancelButtonTitle:@"Dismiss" 
    otherButtonTitles:nil, nil]; 

    [alert show];

如果您想在每次应用启动时提醒用户,请将其放在

 - (void)applicationDidFinishLaunching:(UIApplication *)application {
    }

编辑

你说你想在按下关闭按钮后开始游戏。所以利用UIAlertView delegate

- (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex {

    if (buttonIndex == 0){

        //Start your game!

    }

}
于 2012-08-09T19:52:25.050 回答
0
UIAlertView *message = [[UIAlertView alloc] initWithTitle:@"How to play"
                                                  message:@"Answer the questions correctly to get points blablabla..."
                                                 delegate:nil
                                        cancelButtonTitle:@"OK"
                                        otherButtonTitles:nil];
[message show];
于 2012-08-09T19:52:53.033 回答