博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
选图片
阅读量:6497 次
发布时间:2019-06-24

本文共 1947 字,大约阅读时间需要 6 分钟。

UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"温馨提示" message:@"照片选取" preferredStyle:UIAlertControllerStyleAlert];

UIAlertAction *actionCancel = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
}];
UIAlertAction *actionAlbum = [UIAlertAction actionWithTitle:@"相册" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
if([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypePhotoLibrary])
{
UIImagePickerController *Imagepicker = [[UIImagePickerController alloc] init];
Imagepicker.delegate =self;
Imagepicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
[self presentViewController:Imagepicker animated:YES completion:nil];
}
else{
[self.view makeToast:@"相册未发现"
duration:CLEAR_TIME
position:[NSValue valueWithCGPoint:CGPointMake([UIScreen mainScreen].bounds.size.width/2.f, [UIScreen mainScreen].bounds.size.height-160)]];
}
}];
UIAlertAction *actionCamera = [UIAlertAction actionWithTitle:@"拍照" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
if([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera])
{
UIImagePickerController *picker =[[UIImagePickerController alloc] init];
picker.delegate =self;
// picker.allowsEditing = YES;
picker.sourceType = UIImagePickerControllerSourceTypeCamera;
[self presentViewController:picker animated:YES
completion:^{
}];
}
else{
[self.view makeToast:@"摄像头未发现"
duration:CLEAR_TIME
position:[NSValue valueWithCGPoint:CGPointMake([UIScreen mainScreen].bounds.size.width/2.f, [UIScreen mainScreen].bounds.size.height-160)]];
}
}];
[alertController addAction:actionCancel];
[alertController addAction:actionAlbum];
[alertController addAction:actionCamera];
[self presentViewController:alertController animated:YES completion:nil];

转载于:https://www.cnblogs.com/onlyMyRailGun/p/5633594.html

你可能感兴趣的文章
Java 事件适配器 Adapter
查看>>
poj 3321 Apple Tree
查看>>
【转】 LDA必读的资料
查看>>
百度重置页面自动跳转脚本
查看>>
Unity3D常用代码总结
查看>>
Ubuntu 13.10 安装Terminalx 后更改默认终端设置
查看>>
js中document.write的那点事
查看>>
【WP8】ResourceDictionary
查看>>
Lambda表达式可以被转换为委托类型
查看>>
理解正向索引
查看>>
xp/2003开关3389指令
查看>>
Oracle中merge into的使用
查看>>
iOS 设置UILabel 的内边距
查看>>
Android ViewPager使用具体解释
查看>>
php 命中算法
查看>>
Effective Java - Item 1: Consider static factory methods instead of constructors
查看>>
Spring注解@Component、@Repository、@Service、@Controller,@Autowired、@Resource用法
查看>>
c基础知识复习
查看>>
如何彻底卸载mysql(xp)
查看>>
.net反射详解(转)
查看>>