相机相册跳转
2016-06-16 00:00
183 查看
摘要: 相机相册跳转
-(void)goCameraVC{
self.pickerVC = [[UIImagePickerController alloc]init];
self.pickerVC.sourceType =UIImagePickerControllerSourceTypeCamera;
self.pickerVC.delegate = self;
if (_photoType == SKPhotoTypeEdit) {
//截取
self.pickerVC.allowsEditing = YES;
}else{
//不截取
self.pickerVC.allowsEditing = NO;
}
[self presentViewController:self.pickerVC animated:YES completion:nil];
}
//跳转至选择相片
-(void)goPhotoPickerVC{
self.pickerVC = [[UIImagePickerController alloc]init];
self.pickerVC.sourceType =UIImagePickerControllerSourceTypePhotoLibrary;
self.pickerVC.delegate = self;
if (_photoType == SKPhotoTypeEdit) {
self.pickerVC.allowsEditing = YES;
}else{
self.pickerVC.allowsEditing = NO;
}
[self presentViewController:self.pickerVC animated:YES completion:nil];
}
-(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info{
UIImage* editImage;
if (_photoType == SKPhotoTypeEdit) {
//截取
editImage = info[@"UIImagePickerControllerEditedImage"];
}else{
//不截取
editImage = [info objectForKey:@"UIImagePickerControllerOriginalImage"];
}
NSData* newDataImg=UIImageJPEGRepresentation(editImage,.2);
NSString* imagePath= [newDataImg base64EncodedStringWithOptions:0];
UIImage* newImage = [UIImage imageWithData:newDataImg];
[self.pickerVC dismissViewControllerAnimated:YES completion:nil];
if (_imgInfo) {
_imgInfo(imagePath,newImage,newDataImg);
}
}
-(void)goCameraVC{
self.pickerVC = [[UIImagePickerController alloc]init];
self.pickerVC.sourceType =UIImagePickerControllerSourceTypeCamera;
self.pickerVC.delegate = self;
if (_photoType == SKPhotoTypeEdit) {
//截取
self.pickerVC.allowsEditing = YES;
}else{
//不截取
self.pickerVC.allowsEditing = NO;
}
[self presentViewController:self.pickerVC animated:YES completion:nil];
}
//跳转至选择相片
-(void)goPhotoPickerVC{
self.pickerVC = [[UIImagePickerController alloc]init];
self.pickerVC.sourceType =UIImagePickerControllerSourceTypePhotoLibrary;
self.pickerVC.delegate = self;
if (_photoType == SKPhotoTypeEdit) {
self.pickerVC.allowsEditing = YES;
}else{
self.pickerVC.allowsEditing = NO;
}
[self presentViewController:self.pickerVC animated:YES completion:nil];
}
-(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info{
UIImage* editImage;
if (_photoType == SKPhotoTypeEdit) {
//截取
editImage = info[@"UIImagePickerControllerEditedImage"];
}else{
//不截取
editImage = [info objectForKey:@"UIImagePickerControllerOriginalImage"];
}
NSData* newDataImg=UIImageJPEGRepresentation(editImage,.2);
NSString* imagePath= [newDataImg base64EncodedStringWithOptions:0];
UIImage* newImage = [UIImage imageWithData:newDataImg];
[self.pickerVC dismissViewControllerAnimated:YES completion:nil];
if (_imgInfo) {
_imgInfo(imagePath,newImage,newDataImg);
}
}
相关文章推荐
- View画边框
- 把“\\”转换成“/”
- oracle创建一个用户并授予最高权限
- oracle执行sql plus导入dmp格式数据备份
- 一个线程的独白
- block第一步
- UIAlertController iOS8弹出菜单用法
- 正则表达式验证电话号码
- iOS音频数据读取--AVAssetReader和音频波形图绘制
- 价值的博客链接
- vi tips
- vi tips
- Ubuntu 包管理命令大全
- 我为什么从python转向go
- 结合COMSOL,浅谈多场耦合
- NiceLabel中多个对象怎样同时移动
- 狂猿日记
- 怎样快速修改CODESOFT对话框中的字体
- proftpd的安装和使用
- JPA transaction marked as rollbackonly错误