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 ...
随机推荐
- JSP 中EL表达式用法详解
EL 全名为Expression Language EL 语法很简单,它最大的特点就是使用上很方便.接下来介绍EL主要的语法结构: ${sessionScope.user.sex} 所有EL都是以${ ...
- 转:从编译链接过程解析static函数的用法
关于static函数的用法 就像我们熟知的那样,变量可以分全局的和局部的,函数也可以分全局的和局部的. 比如说,在一个工程的common.h中定义了一个全局变量 int test;那么在整个工程的作用 ...
- HBase之表状态
import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.hbase.HBaseConfiguration; impo ...
- urlencode 和 rawurlencode 的区别
urlencode和rawurlencode的区别urlencode和rawurlencode的区别 $str1 = urlencode(':/?= &#'); $str2 = rawurle ...
- Minimum Path Sum [LeetCode]
Given a m x n grid filled with non-negative numbers, find a path from top left to bottom right which ...
- html5 video标签兼容性与自定义控件
Video不兼容IE8及之前的版本和opera mini. 格式上MPEG4/H.264兼容大部分浏览器,除低版本Firefox和低版本opera,这些可以通过用ogg格式解决,而webm是一种开放. ...
- jQuery经典面试题及答案精选(转)
jQuery是一款非常流行的Javascript框架,如果你想要从事Web前端开发这个岗位,那么jQuery是你必须掌握而且能够熟练应用的一门技术.本文整理了一些关于jQuery的经典面试题及答案,分 ...
- what is archeage honor weapons?
in my opinion,there are many kinds of weapons in archeage online, those include basic weapons and ma ...
- [宽度优先搜索] HDU 1372 Knight Moves
Knight Moves Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Tot ...
- Codeforces 451E Devu and Flowers(组合计数)
题目地址 在WFU(不是大学简称)第二次比赛中做到了这道题.高中阶段参加过数竞的同学手算这样的题简直不能更轻松,只是套一个容斥原理公式就可以.而其实这个过程放到编程语言中来实现也没有那么的复杂,不过为 ...