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

效果图如下:

相关推荐
JS_GGbond10 分钟前
JavaScript入门学习路线图
开发语言·javascript·学习
失败才是人生常态15 分钟前
算法题归类学习
学习·算法
Chunyyyen20 分钟前
【第二十五周】大模型动手学习01
学习
松☆25 分钟前
OpenHarmony + Flutter 混合开发高阶:实现无障碍(Accessibility)与适老化 UI 的深度集成
flutter·ui
d111111111d36 分钟前
STM32外设学习-WDG看门狗-(学习笔记)
笔记·stm32·单片机·嵌入式硬件·学习
数据门徒1 小时前
《人工智能现代方法(第4版)》 第7章 逻辑智能体 学习笔记
人工智能·笔记·学习
不蒸馒头曾口气1 小时前
申论素材学习笔记-以产业振兴激活乡村全面振兴
笔记·学习
小小的橙菜吖!2 小时前
联合体的学习
学习·算法
Chloeis Syntax3 小时前
MySQL初阶学习日记(4)--- 插入、聚合、分组查询 + 数据库约束
数据库·笔记·学习·mysql
盐焗西兰花3 小时前
鸿蒙学习实战之路 - 应用追踪实践最佳实践
学习·华为·harmonyos