UIAlertController 的创建和使用

来源:互联网 发布:中国网络墙叫什么名字 编辑:程序博客网 时间:2024/06/07 02:28
1.第一种表现形式 UIAlertControllerStyleAlert<img src="http://img.blog.csdn.net/20161024165836950?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQv/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center" alt="" />UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"提示" message:@"将清除所有缓存信息" preferredStyle:UIAlertControllerStyleAlert];    //取消    UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {   // 什么都不做    }];    //清除    UIAlertAction *sureAction = [UIAlertAction actionWithTitle:@"清除" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {       // 清除操作     }];    [alertController addAction:cancelAction];    [alertController addAction:sureAction];    [self presentViewController:alertController animated:YES completion:^{    }];2.第二种形式 UIAlertControllerStyleActionSheet<img src="http://img.blog.csdn.net/20161024170145642?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQv/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center" alt="" />1.UIAlertController * alertVC = [UIAlertController alertControllerWithTitle:nil message:nil preferredStyle:UIAlertControllerStyleActionSheet];           2.UIAlertAction * cancelAction = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:nil];           UIAlertAction * photoAction = [UIAlertAction actionWithTitle:@"拍摄视频" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {                 *  调用相机拍            }];UIAlertAction * chosePictureFromUser = [UIAlertAction actionWithTitle:@"选择视频" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {                               *  从相册中选取           }];3.          [alertVC addAction:cancelAction];            [alertVC addAction:photoAction];            [alertVC addAction:chosePictureFromUser];4.[self presentViewController:alertVC animated:YES completion:nil];





0 0
原创粉丝点击