'UIAlertView' is deprecated的解决例子

来源:互联网 发布:义隆单片机 图书 编辑:程序博客网 时间:2024/05/20 05:45

如下代码,

 UIAlertView *alertView=[[UIAlertView alloc]initWithTitle:@"提示" message:@"恭喜你答对了" delegate:nil cancelButtonTitle:@"点击取消" otherButtonTitles:nil];                [alertView show];

会提示:



把代码修改成:


UIAlertController *aleView=[UIAlertController alertControllerWithTitle:@"提示" message:@"恭喜你答对了" preferredStyle:UIAlertControllerStyleAlert];        UIAlertAction *cancel=[UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:nil];        [aleView addAction:cancel];                [self presentViewController:aleView animated:YES completion:nil];

报错消失:


运行后效果如图



阅读全文
0 0
原创粉丝点击