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 ...
随机推荐
- Asp.Net_单点登录
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.We ...
- SSH2 框架下的分页
1.设计分页实体(pageBean) 这里我显示的是3-12页的方式: package cn.itcast.oa.domain; import java.util.List; /** * 封装分页信息 ...
- python3 字典相关函数
python版本3.5 #Author by Liguangbo#_*_ coding:utf-8 _*_'''info={'No.1':'ligb','No.2':'donglx','No.3':' ...
- CEF使用的几个注意点
CEF为chrome浏览器的切入其他浏览器中的轻量级框架. 开发的客户端的时候,这是作为界面显示的首先,可以增强客户的易变性,可塑性. 在开发的过程中(侧重于C,C++解决),遇到的几个问题,以及自己 ...
- 张艾迪(创始人):Hello.世界...
The World No.1 Girl :Eidyzhang The World No.1 Internet Girl :Eidyzhang AOOOiA.global Founder :Eidyzh ...
- 树(二)——二叉树
目录 本章主要讲解内容为: 树的非递归遍历算法,两种版本 树的扩展前缀以及前缀中缀构建方法 源码 btree.cpp btree.h 基础知识 一.定义 二叉树的递归定义:二叉树是每个结点最多含有两棵 ...
- Windows Store App 全球化:在后台代码中引用字符串资源
上文提到了引用字符串资源具有两种方式,分别是在XAML元素中和在后台代码中引用资源文件中的字符串资源.在第一小节已经介绍了如何在XAML元素中引用字符串资源,本小节将讲解在后台代码中引用字符串资源的相 ...
- mac os 中类似于Linux的yum工具,或ubuntu的apt-get工具Homebrew
Linux下的yum用着真省心! mac下的相类似的软件是Homebrew 使用前需要先安装它, ruby -e "$(curl -fsSL https://raw.githubuserco ...
- input输入框输入文字出现清空文字按钮
$("#J_UserName").keyup(function(){ if($("#J_UserName").val() == "" || ...
- 找做IT的男朋友会不会没有隐私
找做IT的男朋友会不会没有隐私你不觉得自己在网上不断的“秀”啊,“晒”啊的行为才是根本所在吗?你应该怕自己的这种行为才对吧-—————————————————————————————————————— ...