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

效果图如下:

相关推荐
学会沉淀。18 小时前
设备如何“开口说话”?
学习
Digitally18 小时前
如何在Mac上同步iPhone短信
macos·ios·iphone
好想早点睡.18 小时前
Mac安装pnpm步骤以及会出现的问题
macos
m0_5913389119 小时前
day10数组的学习
学习
仰望—星空19 小时前
MiniEngine学习笔记 : CommandListManager
c++·windows·笔记·学习·cg·direct3d
电子云与长程纠缠19 小时前
Blender入门学习09 - 制作动画
学习·blender
电子云与长程纠缠19 小时前
Blender入门学习10 - 曲线绘制
学习·blender
下午见。20 小时前
C语言结构体入门:定义、访问与传参全解析
c语言·笔记·学习
im_AMBER20 小时前
React 16
前端·笔记·学习·react.js·前端框架
2501_9151063220 小时前
App HTTPS 抓包 工程化排查与工具组合实战
网络协议·ios·小程序·https·uni-app·php·iphone