IOS调用相机,保存到沙盒
来源:互联网 发布:新郎西服软件 编辑:程序博客网 时间:2024/06/08 06:49
- (IBAction)take_pictures_btn:(id)sender { //设定sourceType为相机 UIImagePickerControllerSourceType sourceType = UIImagePickerControllerSourceTypeCamera; UIImagePickerController *picker = [[UIImagePickerController alloc] init]; picker.delegate = self; picker.allowsEditing = NO; //设置为不可编辑 picker.sourceType = sourceType; [self presentModalViewController:picker animated:YES];//进入照相界面}#pragma mark - image picker delegte- (void) imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info{ [picker dismissViewControllerAnimated:YES completion:^{}]; UIImage *image = [info objectForKey:UIImagePickerControllerOriginalImage]; //压缩图片,格式为JPEG,压缩率为50% NSData *imageData = UIImageJPEGRepresentation(image, 0.5); // 获取沙盒目录 NSString *fullPath = [[NSHomeDirectory() stringByAppendingPathComponent:@"Documents"] stringByAppendingPathComponent:@"image.png"]; // 将图片写入文件 [imageData writeToFile:fullPath atomically:NO]; UIImage *savedImage = [[UIImage alloc] initWithContentsOfFile:fullPath]; [self.imageView setImage:savedImage];}
在.h文件中要加上代理: UINavigationControllerDelegate、UIImagePickerControllerDelegate
0 0
- IOS调用相机,保存到沙盒
- ios 调用系统相机,图库,相册。将照片保存在相册,保存图片在本地,UIImagePickerController
- iOS调用相机详解
- iOS 相机调用
- iOS开发-调用相机
- iOS 调用相机
- iOS开发-调用相机之自定义相机
- iOS调用相机和相册 并编辑保存到本地(个人中心设置头像)
- 调用android系统相机拍照并保存
- 调用android系统相机拍照并保存
- 调用android系统相机拍照并保存
- 调用android系统相机拍照并保存
- 调用android系统相机拍照并保存
- Android调用相机保存图片到相册
- 调用android系统相机拍照并保存
- 调用系统相机进行拍照并保存
- 调用android系统相机拍照并保存
- ios系统相机的调用
- 社交软件强势来袭,谁来革新中国企业管理模式?
- DAl、BLL与一般处理程序
- 浏览器兼容性问题css+js
- 从SVN导出指定版本号之间修改的文件(转)
- TextField编辑中状态判读
- IOS调用相机,保存到沙盒
- Windbg连不上VMware虚拟机的原因
- 电脑组装与维修完全学习手册 pdf电子书
- boost::asio---深入框架
- 去除 字符串中空格/回车
- w_chart*(LPTSTR)和char*相互转换
- Android开发之Intent.Action 各个属性说明
- Linux ALSA声卡驱动之二:声卡的创建
- 960 CSS框架