小工具知识网

当前位置: 首页 > 行业知识 > iOS-系统弹窗调用

行业知识

iOS-系统弹窗调用

2026-11-15 18:28:14 来源:互联网转载

代���:

UIAlertController *alertViewController = [UIAlertController alertControllerWithTitle:@"请选择方式" message:nil preferredStyle:UIAlertControllerStyleActionSheet];// style 为 sheetUIAlertAction *cancle = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:nil];UIAlertAction *picture = [UIAlertAction actionWithTitle:@"相册" style:UIAlertActionStyleDefault handler:nil];//handler里可以写需要的函数UIAlertAction *photo = [UIAlertAction actionWithTitle:@"相机" style:UIAlertActionStyleDefault handler:nil];//同理[alertViewController addAction:cancle];[alertViewController addAction:photo];[alertViewController addAction:picture];[self presentViewController:alertViewController animated:YES completion:nil];

handle处理格式如下:

UIAlertAction *picture = [UIAlertAction actionWithTitle:@"相册" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {    }];//handler里可以写需要的函数

效果图如下:

上一篇:服务器数据怎么备份好呢?

下一篇:如何代理服务器怎么设置?