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

效果图如下:

相关推荐
茶底世界之下3 小时前
导出进度不是一个百分比:AVFoundation 收尾阶段的状态建模
ios·swift
用户2181697049303 小时前
FFmpeg (二) shell echo 数组
objective-c
大熊猫侯佩3 小时前
macOS27 上可变界面尺寸 iOS App 揭秘
macos·ios·swiftui
tangzzzfan3 小时前
把 ADB 装进 macOS app
macos
大熊猫侯佩3 小时前
iPhone Duo 从外屏到内屏:ArrangementView 抢先适配
swiftui·xcode·apple
用户2181697049303 小时前
LLVM
ios
zeqinjie3 小时前
Flutter 获取 iPhone Duo 预留区位置
前端·flutter·ios
二流小码农3 小时前
鸿蒙开发:ArrayList,可不会让UI更新哦
android·ios·harmonyos
一隅论数智6 天前
给AI一张“业务概念地图“:本体如何从哲学走向企业智能
大数据·人工智能·经验分享·笔记·学习·学习方法·政务