相机学习
来源:互联网 发布:淘宝店想改店铺名 编辑:程序博客网 时间:2024/06/09 19:13
- @interface ViewController ()<UIImagePickerControllerDelegate,UINavigationControllerDelegate>
- @property (weak, nonatomic) IBOutlet UIImageView *imView;
- @end
- @implementation ViewController
- {
- UIImagePickerController *_imPicker;
- }
- - (IBAction)takePicture:(id)sender
- {
- //make sure camera is available
- if([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera] == NO)
- {
- //camera is not available
- return;
- }
- if (_imPicker == nil) {
- _imPicker = [[UIImagePickerController alloc] init];
- _imPicker.delegate = self;
- _imPicker.sourceType = UIImagePickerControllerSourceTypeCamera;
- }
- [self presentViewController:_imPicker animated:YES completion:nil];
- }
取图片
- - (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
- {
- UIImage *im = [info objectForKey:UIImagePickerControllerOriginalImage];
- [_imView setImage:im];
- _imView.contentMode = UIViewContentModeScaleAspectFill;
- [self dismissViewControllerAnimated:YES completion:nil];
- }
取消图片选择
- - (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker
- {
- [self dismissViewControllerAnimated:YES completion:nil];
- }
实现可编辑
- - (IBAction)takePicture:(id)sender
- {
- //make sure camera is available
- if([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera] == NO)
- {
- //camera is not available
- return;
- }
- if (_imPicker == nil) {
- _imPicker = [[UIImagePickerController alloc] init];
- _imPicker.delegate = self;
- _imPicker.sourceType = UIImagePickerControllerSourceTypeCamera;
- _imPicker.allowsEditing = YES;//相机界面处于可编辑状态
- }
- [self presentViewController:_imPicker animated:YES completion:nil];
- }
- - (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
- {
- UIImage *im = [info objectForKey:UIImagePickerControllerEditedImage];//修改key
- UIImageWriteToSavedPhotosAlbum(im, nil, nil, nil);//保存到相册
- [_imView setImage:im];
- _imView.contentMode = UIViewContentModeScaleAspectFill;
- [self dismissViewControllerAnimated:YES completion:nil];
- }
0 0
- 相机学习
- IOS相机使用学习笔记
- Unity3d学习 相机的跟随
- opencv中的相机标定学习
- 相机标定 calib3d 学习笔记
- 学习总结:相机界面组成
- 学习总结:相机界面组成
- 相机
- 相机
- 相机
- 相机
- 相机
- 相机
- 相机
- 相机
- 相机
- XNA学习笔记——相机设置
- android学习笔记36--------------简单的相机
- jQuery的选择器中的通配符[id^='code']
- C++ 标准模板库STL 队列 queue 使用方法与应用介绍(一)
- github.global.ssl.fastly.net hosts
- SQL SERVER创建和更新统计信息
- response.sendRedirect的使用
- 相机学习
- 1175. You are using safe update mode
- XP进军中国,Linux奋起反击
- mysql外键设置详解
- ubuntu下ATI/Intel双显卡切换的方法
- [置顶] 一个小马
- 第二十章,生与死的较量之回忆(下)
- 文件上传下载struts2
- http常见状态吗及说明