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

效果图如下:

相关推荐
科技林总1 分钟前
【系统分析师】8.0 项目管理
学习
浅念-15 分钟前
C++ string类
开发语言·c++·经验分享·笔记·学习
Purple Coder28 分钟前
基于神经网络的家教系统
学习
前端不太难1 小时前
Flutter 适合什么团队?RN / iOS 各自的边界在哪?
flutter·ios
victory04312 小时前
LangChain + LangGraph 学习路径
学习·langchain
专业开发者3 小时前
Wi-Fi 技术学习:Wi-Fi 射频设计核心原则 —— 只覆盖你想要的区域
学习
码农葫芦侠6 小时前
Rust学习教程2:基本语法
开发语言·学习·rust
LYS_06186 小时前
c++学习(1)(编译过程)
c++·学习
happymaker06267 小时前
Java学习日记——DAY25(JavaSE完结)
java·开发语言·学习
qq_24218863327 小时前
快速搭建跨环境检测服务的步骤
linux·开发语言·windows·python·macos