iOS红马甲项目Bug总结(2)
背景:iOS调用相机和访问图库
一、调用相机或图库:
-(void)imgviewClick
{
ALAuthorizationStatus author = [ALAssetsLibrary authorizationStatus];
AVAuthorizationStatus authStatus = [AVCaptureDevice authorizationStatusForMediaType:AVMediaTypeVideo];
UIAlertController *alertvc=[UIAlertController alertControllerWithTitle:nil message:nil preferredStyle:UIAlertControllerStyleActionSheet];
UIAlertAction *cameraAction =[UIAlertAction actionWithTitle:@"相机" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
UIImagePickerController *picker=[[UIImagePickerController alloc]init];
if(authStatus == ALAuthorizationStatusRestricted || authStatus == ALAuthorizationStatusDenied){
[self resultHud:@"请在设置中打开您的相机权限!"];
// // 无权限 引导去开启相机
// NSURL *url = [NSURL URLWithString:UIApplicationOpenSettingsURLString];
// if ([[UIApplication sharedApplication]canOpenURL:url]) {
// [[UIApplication sharedApplication]openURL:url];
return;
}
else{
if([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera])
{
picker.sourceType=UIImagePickerControllerSourceTypeCamera;
picker.editing=YES;
picker.allowsEditing=YES;
picker.delegate=self;
[self presentViewController:picker animated:YES completion:nil];
}
else
{
[self resultHud:@"未检测到相机!"];
}
}
}];
UIAlertAction *libraryAction =[UIAlertAction actionWithTitle:@"照片图库" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
UIImagePickerController *picker=[[UIImagePickerController alloc]init];
if(author == ALAuthorizationStatusRestricted || author == ALAuthorizationStatusDenied){
[self resultHud:@"请在设置中打开您的相册权限!"];
// NSURL *url = [NSURL URLWithString:UIApplicationOpenSettingsURLString];
// if ([[UIApplication sharedApplication] canOpenURL:url]) {
// [[UIApplication sharedApplication] openURL:url];
// }
return;
}
else{
if([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypePhotoLibrary])
{
picker.sourceType=UIImagePickerControllerSourceTypePhotoLibrary;
picker.editing=YES;
picker.allowsEditing=YES;
picker.delegate=self;
[self presentViewController:picker animated:YES completion:nil];
}
else
{
[self resultHud:@"未检测到图库!"];
}
}
}];
UIAlertAction *cancleAction=[UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:nil];
[alertvc addAction:libraryAction];
[alertvc addAction:cameraAction];
[alertvc addAction:cancleAction];
[self presentViewController:alertvc animated:YES completion:nil];
}
⚠️注意:1、为什么打开图库后 或者打开相机操作完之后,一直不会返回你原先的界面: [self presentViewController:alertvc animated:YES completion:nil];
因为你需要将pickerviewcontroller dimiss掉,pickerviewcontroller 的调用就是通过原控制器调用present方法实现的,所以可以用dismiss关闭
2、灰色部分表示,直接调用应用程序的设置界面,带领用户去开启权限
二、编辑选择的图片并关闭图像选择控制器
-(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary<NSString *,id> *)info
{
NSLog(@"info--->%@",info);
UIImage *originaImage =[info objectForKey:UIImagePickerControllerEditedImage];
_headimgView.image=originaImage;
originaImage=[self imageWithImage:originaImage scaledToSize:CGSizeMake(IMG_SECTION_HEIGHT,IMG_SECTION_HEIGHT)];
[self dismissViewControllerAnimated:YES completion:nil];
}
可以在图像编辑中完成你之后想借用相机选择图片之后,要实现的例如上传图像等操作
⚠️注意:我这里打印出来的info 就是图像选择器完成之后,返回的数据,根据打印出来的数据你可以发现,返回的图像有两种类型
1、UIImagePickerControllerEditedImage 2、UIImagePickerControllerOriginaImage
UIImagePickerControllerEditedImage 这个代表你在图像选择器中选择的图片在选择框中是怎么样的返回的就是怎么样的
UIImagePickerControllerOriginaImage 这个表示,不管你在图像选择器的选择框内将图片是方法还是缩小,返回的都是原图,未经过任何操作。
iOS红马甲项目Bug总结(2)的更多相关文章
- iOS红马甲项目Bug总结(3)
这里是一些小总结 1.使用图片缓存之后,新添加的图像一直不能显示 2.项目打包通过appliction loader上传成功了,可是itunes 上面的构建版本项,一直没显示出来 3.界面加载之后,t ...
- iOS红马甲项目开发过程Bug总结(1)
在上线审核时,重新检测自己的app发现报错:"was compiled with optimization - steppingmay behave oddly; variables may ...
- iOS开源项目周报0105
由OpenDigg 出品的iOS开源项目周报第四期来啦.我们的iOS开源周报集合了OpenDigg一周来新收录的优质的iOS开发方面的开源项目,方便iOS开发人员便捷的找到自己需要的项目工具等. He ...
- iOS开源项目周报1229
由OpenDigg 出品的iOS开源项目周报第三期来啦.我们的iOS开源周报集合了OpenDigg一周来新收录的优质的iOS开发方面的开源项目,方便iOS开发人员便捷的找到自己需要的项目工具等. Ma ...
- iOS开源项目周报1222
由OpenDigg 出品的iOS开源项目周报第二期来啦.我们的iOS开源周报集合了OpenDigg一周来新收录的优质的iOS开发方面的开源项目,方便iOS开发人员便捷的找到自己需要的项目工具等. io ...
- iOS开源项目周报1215
由OpenDigg 出品的iOS开源项目周报第一期来啦.我们的iOS开源周报集合了OpenDigg一周来新收录的优质的iOS开发方面的开源项目,方便iOS开发人员便捷的找到自己需要的项目工具等. PY ...
- iOS Waxpatch项目(动态更新)
我的iOS Waxpatch项目地址https://github.com/piaojin/iOS-WaxPatch
- iOS原生项目中集成React Native
1.本文的前提条件是,电脑上已经安装了CocoaPods,React Native相关环境. 2.使用Xcode新建一个工程.EmbedRNMeituan [图1] 3.使用CocoaPods安装Re ...
- 直接拿来用!最火的iOS开源项目
1. AFNetworking 在众多iOS开源项目中,AFNetworking可以称得上是最受开发者欢迎的库项目.AFNetworking是一个轻量级的iOS.Mac OS X网络通信类库,现在是G ...
随机推荐
- python的class的__str__()和__repr__()函数
repr(object) 返回一个可以用来表示对象的可打印字符串首先,尝试生成这样一个字符串,将其传给 eval()可重新生成同样的对象 否则,生成用尖括号包住的字符串,包含类型名和额外的信息(比如地 ...
- json化 datatable
/// <summary> /// 将DataSet中数据,json化 /// </summary> /// <param name="source" ...
- rpc选择标准
衡量RPC好用与否的几条标准: 真的像本地函数一样调用 使用简单,用户只需要关注业务即可 灵活,RPC调用的序列化方式可以自由定制,比如支持json,支持msgpack等方式 http://www.o ...
- 课时9—popup
内容比较多的时候可以全屏显示,用第一种实现方式,如图1 图1 内容较少的话可以使用第二种实现方式如图2:图2 具体的实现代码如下: .header,.footer,.wrap-page{ positi ...
- 6/8/9/10/11 Sprint2 看板和燃尽图
端午放假,大家都回家了 页面模块的大体设计,因所找的资料不全,还待改善
- Linux系统资源监控命令
转自http://www.51testing.com/html/16/271416-149128.html 衡量CPU性能的指标: 1,用户使用CPU的情况:CPU运行常规用户进程CPU运行niced ...
- [笔记]CSS样式声明顺序
来自Bootstrap中文网编程规范 相关的属性声明应当归为一组,并按照下面的顺序排列: Positioning Box model Typographic Visual .declaration-o ...
- [转]jQuery.validate插件在失去焦点时执行验证代码
转:http://my.oschina.net/enyo/blog/311566 关于 jquery.validate.js 表单验证插件如何在失去焦点时做验证.看手册后发现默认是在表单提交时执行验证 ...
- Redis + php扩展的安装与配置(windows)
-->安装Redis服务 下载redis安装包 http://pan.baidu.com/s/1pJiVFHx 下载后解压 把解压后文件夹里面的文件(根据自己的系统位数选择32位或者64位)拷贝 ...
- 如何有效使用Project(2)——进度计划的执行与监控
继上次的的<编制进度计划.保存基准>继续讲解如何对计划进行执行和监控. 计划执行即:反馈实际进度.反馈工作消耗(本文只考虑工时,不考虑成本).提出计划变更请求.如果你的企业实施了专门的PM ...