【发布时间】:2016-12-18 12:53:24
【问题描述】:
我目前有一个 UIAlertController,我需要将其设为不可解雇。按下操作按钮时,警报不应关闭。
我该怎么做?
UIAlertController *alert;
int bestScore = [[[NSUserDefaults standardUserDefaults] objectForKey:@"bestScore"] intValue];
if (!bestScore || bestScore < _score){
[[NSUserDefaults standardUserDefaults] setObject:@(_score) forKey:@"bestScore"];
alert = [UIAlertController alertControllerWithTitle:@"GAME OVER "
message:[NSString stringWithFormat:@"NEW RECORD! \n SCORE : %d \n\n\n\n\n\n", _score] preferredStyle:UIAlertControllerStyleActionSheet];
}
else alert = [UIAlertController alertControllerWithTitle:@"GAME OVER"
message:[NSString stringWithFormat:@"SCORE : %d \n Best score : %d \n\n\n\n\n\n ", _score, bestScore] preferredStyle:UIAlertControllerStyleAlert];
[alert addAction:[UIAlertAction actionWithTitle:@"Try again" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
[self newGame];
[self addNewView];
}]];
[alert addAction:[UIAlertAction actionWithTitle:@"Answer" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
[alert viewWillDisappear:NO];
}]];
[self presentViewController:alert animated:YES completion:nil];
【问题讨论】:
-
您将需要使用/创建一些其他技术来显示您的信息。只要点击其中一个按钮,警报控制器就会被关闭
-
UIAlertController是系统alert,不能修改,建议写custom alert。
标签: ios objective-c uialertview uialertcontroller