在游戏开始前提醒说明

时间:2012-08-09 19:49:04

标签: iphone ios uialertview

如何在游戏开始前添加显示说明的提醒:

见下面的代码:

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

2 个答案:

答案 0 :(得分: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!

    }

}

答案 1 :(得分: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];