Xcode7.0之后的UIAlertController的用法
Xcode7.0之后的UIAlertView 改成了UIAlertController,用法也同样简单。主要增加了UIAlertController和UIAlertAction两个类。
- UIAlertController
- UIAlertAction
代码块
简单的弹出框实现,可写入到方法的实现中
UIAlertController *alc = [UIAlertController alertControllerWithTitle:@"编辑头像" message:nil preferredStyle:UIAlertControllerStyleActionSheet];
[alc addAction:[UIAlertAction actionWithTitle:@"拍照" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
NSLog(@"拍照");
}]];
[alc addAction:[UIAlertAction actionWithTitle:@"从相册选择" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
NSLog(@"从相册选择");
}]];
[alc addAction:[UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
NSLog(@"从相册选择");
}]];
[self presentViewController:alc animated:YES completion:nil];