iOS-系统弹窗调用,

代码:

复制代码
UIAlertController *alertViewController = [UIAlertController alertControllerWithTitle:@"请选择方式" message:nil preferredStyle:UIAlertControllerStyleActionSheet];// style 为 sheet
UIAlertAction *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) {
    <#code#>
}];//handler里可以写需要的函数

效果图如下:

相关推荐
hnlucky7 分钟前
Windows 上安装下载并配置 Apache Maven
java·hadoop·windows·学习·maven·apache
SoraLuna11 分钟前
「Mac畅玩AIGC与多模态41」开发篇36 - 用 ArkTS 构建聚合搜索前端页面
前端·macos·aigc
~巴哥~24 分钟前
mcp学习笔记
笔记·学习
有梦想的攻城狮1 小时前
mac本地docker镜像上传指定虚拟机
macos·docker·eureka
lichuangcsdn1 小时前
【springcloud学习(dalston.sr1)】Eureka 客户端服务注册(含源代码)(四)
学习·spring cloud·eureka
云海听雷3 小时前
C语言中字符串函数的详细讲解
c语言·笔记·学习
深井冰水3 小时前
Pycharm的终端执行allure命令出现command not found
macos·pycharm·接口自动化
黄昏贩卖机3 小时前
mac latex vscode 配置
ide·vscode·macos
人类恶.4 小时前
C 语言学习笔记(数组)
c语言·笔记·学习
夏季疯4 小时前
学习笔记:黑马程序员JavaWeb开发教程(2025.4.7)
java·笔记·学习