您的位置:首页 > 其它

相机相册跳转

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);

}

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: