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

效果图如下:

相关推荐
克里斯蒂亚诺·罗纳尔达7 分钟前
智能体学习23——资源感知优化(Resource-Aware Optimization)
人工智能·学习
90后的晨仔40 分钟前
第3章:基础视图组件
ios
小夏子_riotous1 小时前
Docker学习路径——2、安装
linux·运维·分布式·学习·docker·容器·云计算
SteveSenna1 小时前
Trossen Arm MuJoCo自定义1:改变目标物体
人工智能·学习·算法·机器人
U盘失踪了2 小时前
go 环境配置
学习
Stella Blog2 小时前
狂神Java基础学习笔记Day03
java·笔记·学习
夜瞬4 小时前
NLP学习笔记02:文本表示方法——从词袋模型到 BERT
笔记·学习·自然语言处理
xuhaoyu_cpp_java4 小时前
MySql学习(二)
经验分享·笔记·学习·mysql
你叶不叶4 小时前
sap rap 的技术开发自己的学习路径
学习
厚皮龙4 小时前
VAE 与世界模型学习总结
学习