iOS8中新增了UIAlertViewController,用来统一之前的UIAlertView和UIActionSheet.但是个人觉得某些情况下不太适用,因为UIAlertViewController继承自UIViewController,只能用
presentViewController:animated:completion
方法来展示,这样的话在一些UIView的业务场景下就不好处理了.
但是UIAlertViewController来展示UITextField的时候可以自由订制使用所有的UITextField特性了,UIAlertView只能使用系统固定的样式.
oc代码:
- (IBAction)showAlert:(id)sender {
UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"This is title" message:@"This is message" preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction *ok = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
NSLog(@"OK");
}];
UIAlertAction *cancel = [UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {
NSLog(@"Cancel");
}];
UIAlertAction *Destructive = [UIAlertAction actionWithTi