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

效果图如下:

相关推荐
moxiaoran575330 分钟前
uni-app学习笔记二十三--交互反馈showToast用法
笔记·学习·uni-app
I烟雨云渊T7 小时前
iOS 门店营收表格功能的实现
ios
weixin_387545647 小时前
如何把 Mac Finder 用得更顺手?——高效文件管理定制指南
macos
恰薯条的屑海鸥8 小时前
零基础在实践中学习网络安全-皮卡丘靶场(第十六期-SSRF模块)
数据库·学习·安全·web安全·渗透测试·网络安全学习
喜欢吃燃面8 小时前
C++刷题:日期模拟(1)
c++·学习·算法
2301_797604249 小时前
学习记录:DAY32
学习
蓝婷儿10 小时前
6个月Python学习计划 Day 16 - 面向对象编程(OOP)基础
开发语言·python·学习
叶子20242210 小时前
学习使用YOLO的predict函数使用
人工智能·学习·yolo
jackson凌10 小时前
【Java学习笔记】SringBuffer类(重点)
java·笔记·学习
itme26811 小时前
解决cocos 2dx/creator2.4在ios18下openURL无法调用的问题
macos·objective-c·cocoa