iOS开发Xcode编译错误解决

iOS:小警告⚠️'UIAlertView' i

2017-04-19  本文已影响94人  iOS技术小卒
UIAlertView小警告

【“ 'UIAlertView' is deprecated: first deprecated in iOS 9.0 - UIAlertView is deprecated. Use UIAlertController with a preferredStyle of UIAlertControllerStyleAlert instead”】

【deprecated:过去的;反对】


解决方法一:

UIAlertController是iOS8以后才出现的类,如果你的项目需要兼容iOS7,恐怕你不能使用这个类,否则会崩溃的。你要是觉得黄色的警告看着不爽,可以这样。

#pragma clang diagnostic push

#pragma clang diagnostic ignored"-Wdeprecated-declarations"

//这里是会报警告的代码

#pragma clang diagnostic pop


解决方法、二

提示框

UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"保存" message:@"保存文档吗" preferredStyle:UIAlertControllerStyleAlert];

UIAlertAction *cancel  =[UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:nil];

UIAlertAction *sure  =[UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:nil];

[alertController addAction:cancel];

[alertController addAction:sure];

[self presentViewController:alertController animated:YES completion:nil];

上一篇 下一篇

猜你喜欢

热点阅读