似乎不能使用UIAlertview,我该怎么办? 我尝试过使用UIAlertviewcontroller,但都无济于事。任何帮助将不胜感激。
答案 0 :(得分:1)
UIAlertView是一种弃用的方法。请参阅此SO post。
UIAlertController * alert = [UIAlertController
alertControllerWithTitle:@"Title"
message:@"Finished! \nYour results"
preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction* restartButton = [UIAlertAction
actionWithTitle:@"Restart"
style:UIAlertActionStyleDefault
handler:^(UIAlertAction * action) {
//Your restart button action goes here
}];
[alert addAction:restartButton];
[self presentViewController:alert animated:YES completion:nil];
答案 1 :(得分:0)
//使用此更新的警报视图代码...
UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"Title"
message:@"Message"
preferredStyle:UIAlertControllerStyleAlert];
//我们通过创建UIAlertActions向警报控制器添加按钮:
UIAlertAction *actionOk = [UIAlertAction actionWithTitle:@"Ok"
style:UIAlertActionStyleDefault
handler:nil]; //You can use a block here to handle a press on this button
[alertController addAction:actionOk];
[self presentViewController:alertController animated:YES completion:nil];