首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >游戏开始前使用说明进行警报

游戏开始前使用说明进行警报
EN

Stack Overflow用户
提问于 2012-08-10 03:49:04
回答 2查看 53关注 0票数 0

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

请看下面的代码:

代码语言:javascript
复制
- (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]];
    }
}
EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2012-08-10 03:52:25

使用UIAlertView

代码语言:javascript
复制
    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Instructions" 
    message:@"Your Instructions..." delegate:self cancelButtonTitle:@"Dismiss" 
    otherButtonTitles:nil, nil]; 

    [alert show];

如果希望在应用程序每次启动时都向用户发出警报,请将其放在

代码语言:javascript
复制
 - (void)applicationDidFinishLaunching:(UIApplication *)application {
    }

编辑

你说你想在按下解散按钮后开始游戏。所以要充分利用UIAlertView delegate

代码语言:javascript
复制
- (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex {

    if (buttonIndex == 0){

        //Start your game!

    }

}
票数 0
EN

Stack Overflow用户

发布于 2012-08-10 03:52:53

代码语言:javascript
复制
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];
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/11890891

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档