在iOS7之前的彈窗都是使用的傳統(tǒng)的UIAlertView栗恩,代碼如下:
//創(chuàng)建彈框
UIAlertView *alertView = [[UIAlertView alloc]initWithTitle:@"提示" message:@"輸入的數(shù)字不合理" delegate:nil cancelButtonTitle:@"取消" otherButtonTitles:nil, nil];
//顯示彈框
[alertView? show];
在iOS8以來的彈框方式變?yōu)椋?/p>
//? ? ? ? ? ? ? ? 2.3.1創(chuàng)建一個彈框
UIAlertController *alertVc = [UIAlertController alertControllerWithTitle:@"提示" message:@"輸入的數(shù)字不合理" preferredStyle:UIAlertControllerStyleAlert];
//? ? ? ? 2.3.2添加取消按鈕
[alertVc addAction:[UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:nil]];
//? ? ? ? 2.3.3.顯示
[self presentViewController:alertVc animated:NO completion:nil];