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

效果图如下:

相关推荐
少云清2 小时前
【UI自动化测试】3_TPshop项目实战 _一个测试用例脚本编写过程
ui·测试用例
Jasmine8392 小时前
OpenClaw部署太难? Codex全流程零编码实现浏览器UI自动化
人工智能·测试工具·ui
好奇龙猫3 小时前
【日语学习-日语知识点小记-日本語体系構造-JLPT-N2前期阶段-第一阶段(19):単語文法】
学习
低调小一4 小时前
macOS 自带终端(Terminal.app)提效配置:最小工具链与工作流
macos
符哥20085 小时前
新能源智能充电桩与 Android/iOS App 蓝牙通信协议
android·ios
Nan_Shu_6147 小时前
学习: 尚硅谷Java项目之小谷充电宝(3)
java·后端·学习
这个人中暑了7 小时前
iOS 查看手机udid
ios·智能手机
头疼的程序员7 小时前
计算机网络:自顶向下方法(第七版)第三章 学习分享(二)
网络·学习·计算机网络
星期五不见面7 小时前
AI学习(三)openclow启动(2)2026/03/05
学习
Digitally7 小时前
如何通过蓝牙将 iPhone 上的照片传输到 Android
android·ios·iphone