直接代码敬之

@import MobileCoreServices;

@import AVFoundation;

<UIImagePickerControllerDelegate,UINavigationControllerDelegate>

get方法

- (UIImagePickerController*)imagePicker{

if (!_imagePicker) {

_imagePicker = [[UIImagePickerController alloc]init];

//_imagePicker.sourceType = UIImagePickerControllerSourceTypeSavedPhotosAlbum;

_imagePicker.sourceType = UIImagePickerControllerSourceTypeCamera;

_imagePicker.cameraDevice = UIImagePickerControllerCameraDeviceRear;//摄像头分前后

_imagePicker.allowsEditing= NO;

//_imagePicker.allowsImageEditing = YES;

UIButton *button = [UIButton buttonWithType:UIButtonTypeSystem];

[button setBackgroundColor:[UIColor yellowColor]];

[button setFrame:CGRectMake(80, 580, 50, 50)];

button.layer.cornerRadius = 25.0;

[_imagePicker.cameraOverlayView addSubview:button];

_imagePicker.showsCameraControls = NO;

// _imagePicker.cameraViewTransform = CGAffineTransformMakeRotation(M_PI_2);

_imagePicker.delegate = self;

}

return _imagePicker;

}

事件响应实现跳转:注意貌似不能在viewdidload中操作

[self presentViewController:self.imagePicker animated:YES completion:nil];

#pragma   - mark    UIImagePickerControllerDelegate

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingImage:(UIImage *)image editingInfo:(NSDictionary *)editingInfo {

NSLog(@"%s",__func__);

}

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info{

UIImage *image = [[UIImage alloc]init];

if (self.imagePicker.allowsEditing) {

image = [info objectForKey:UIImagePickerControllerEditedImage];

}else{

image = [info objectForKey:UIImagePickerControllerOriginalImage];

}

_img.image = image;

[self.imagePicker dismissViewControllerAnimated:YES completion:nil];

NSLog(@"%s",__func__);

}

- (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker{

[self dismissViewControllerAnimated:YES completion:nil];

NSLog(@"cancel");

}

iOS之UIImagePickerController的应用的更多相关文章

  1. iOS开发—— UIImagePickerController获取相册和拍照

    一.简单的拍照显示,或是从相册中直接选取照片 #import "ViewController.h" @interface ViewController ()<UIImageP ...

  2. 【Xamarin】MonoTouch - iOS 使用 UIImagePickerController 打开图片库和相机选择图片修改头像

    Application tried to present modally an active controller <UIImagePickerController: 0x7b6ff400> ...

  3. iOS之UIImagePickerController显示中文界面

    iOS开发中,我们经常遇到获取拍照.相册中图片的功能,就必然少不了UIImagePickerController,但是我们发现当我们使用它的时候,它的页面是英文的,看着很别扭,国人还是比较喜欢看中文界 ...

  4. IOS中UIImagePickerController中文界面问题

    今天沈阳斌子,写IOS项目遇到一个调用照相机的问题,找到解决方法,高速攻克了拿给PM看,结果PM说程序调用的照相机不是中文的是英文的.必须改成中文.上网找到了方法.试用后好用拿出来和大家分享.方法例如 ...

  5. UIImagePickerController 视频录制操作,视频大小,时间长度

    一:使用 iOS 系统 UIImagePickerController 获取视频大小 获取视频长度 - (void)viewDidLoad { [super viewDidLoad]; // Do a ...

  6. IOS开发之小实例--使用UIImagePickerController创建一个简单的相机应用程序

    前言:本篇博文是本人阅读国外的IOS Programming Tutorial的一篇入门文章的学习过程总结,难度不大,因为是入门.主要是入门UIImagePickerController这个控制器,那 ...

  7. iOS摄像头和相册-UIImagePickerController常用操作

    在一些应用中,我们需要用到iOS设备的摄像头进行拍照,视频.并且从相册中选取我们需要的图片或者视频. 关于iOS摄像头和相册的应用,可以使用UIImagePickerController类来完成控制. ...

  8. IOS开发UI基础UIImagePickerController的属性

    UIImagePickerController 1.+(BOOL)isSourceTypeAvailable:(UIImagePickerControllerSourceType)sourceType ...

  9. iOS - UIImagePickerController

    前言 NS_CLASS_AVAILABLE_IOS(2_0) @interface UIImagePickerController : UINavigationController <NSCod ...

随机推荐

  1. python 运行python manege.py runserver时报错:“no module named djangorestframework” 的解决方案

    python 运行python manege.py runserver时报错:“no module named djangorestframework” 的解决方案 importerror:no mo ...

  2. 多校3- RGCDQ 分类: 比赛 HDU 2015-07-31 10:50 2人阅读 评论(0) 收藏

    RGCDQ Time Limit:3000MS Memory Limit:65536KB 64bit IO Format:%I64d & %I64u Submit Status Practic ...

  3. 山东理工大学第七届ACM校赛-飞花的线代 分类: 比赛 2015-06-26 10:29 10人阅读 评论(0) 收藏

    飞花的线代 Time Limit: 1000ms Memory limit: 65536K 有疑问?点这里^_^ 题目描述 飞花壕的线代一直非常的壕(好),线代考试每次都是全班第一.一次,飞花壕在预习 ...

  4. JAVA基础知识之List集合

    List接口和ListIterator接口介绍 List集合新增方法 List集合判断元素重复的标准 ListIterator List.ArrayList和List.Vector 固定长度的List ...

  5. Uva 1599 最佳路径

    题目链接:https://uva.onlinejudge.org/external/15/1599.pdf 题意: 保证在最短路的时候,输出字典序最小的路径. 方法: 路径上有了权值,可以利用图论的数 ...

  6. CountDownLatch的原理学习

    转载:http://blog.csdn.net/yanyan19880509/article/details/52349056 前言 前面介绍了ReentrantLock,又叫排他锁,本篇主要通过Co ...

  7. Spring资源访问

    资源访问 1.Resource Jdk提供的访问资源的类并不能很好地满足各种底层的资源访问需求, 比如缺少从类路径或者web容器的上下文中获取资源的操作类. 鉴于此, Spring设计了一个Resou ...

  8. 2016年11月25日 星期五 --出埃及记 Exodus 20:16

    2016年11月25日 星期五 --出埃及记 Exodus 20:16 "You shall not give false testimony against your neighbor.不 ...

  9. UIView如何管理它的子视图

    UIView提供了很多建立和管理视图的方法. 1.添加视图 insertSubview:atIndex:   //放在子视图数组的具体索引位置 insertSubview:aboveSubview:  ...

  10. 遇到问题-----JS中设置window.location.href跳转无效(在a标签里或这form表单里)

    问题情况 JS中设置window.location.href跳转无效 代码如下: ? 1 2 3 4 5 6 7 8 <script type="text/javascript&quo ...