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里可以写需要的函数

效果图如下:

相关推荐
今儿敲了吗14 分钟前
python基础学习笔记第三章
笔记·python·学习
MonkeyKing_sunyuhua21 分钟前
K8S执行MAC打出的本地镜像错误:exec /usr/local/bin/uvicorn: exec format error
macos·容器·kubernetes
hua8722238 分钟前
Golang 构建学习
java·开发语言·学习
试试勇气3 小时前
Linux学习笔记(十七)--线程概念
linux·笔记·学习
weixin_458872613 小时前
东华复试OJ二刷复盘12
学习
·醉挽清风·3 小时前
学习笔记—Linux—文件系统
linux·笔记·学习
科技林总3 小时前
【系统分析师】12.1 软件架构的概念
学习
FC皇家慕尼黑4 小时前
Claude Code学习--从搭建Nano Claude Code学习CC机制的底层原理
学习·ai·claude code
happymaker06264 小时前
web前端学习日记——DAY01(HTML基本标签)
前端·学习·html
FC皇家慕尼黑4 小时前
Claude Code学习--从搭建Nano Claude Code学习CC机制的底层原理pt2
学习·ai·claude code