@interface BNRDetailViewController ()<UINavigationControllerDelegate,UIImagePickerControllerDelegate>
@property (weak, nonatomic) IBOutlet UIImageView *imageView;
@property (weak, nonatomic) IBOutlet UIToolbar *toolBar;
@end
@implementation BNRDetailViewController
- (IBAction)takePicture:(id)sender {
UIImagePickerController *imagePicker=[[UIImagePickerController alloc]init];
if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) {
imagePicker.sourceType = UIImagePickerControllerSourceTypeCamera;
} else {
imagePicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
}
imagePicker.delegate = self;
imagePicker.allowsEditing = YES;
// 模态形式显示uiimagepickercontroller对象
[self presentViewController:imagePicker animated:YES completion:NULL];
}
@end
怪我咯2017-04-18 09:49:46
UIImagePickerControllerDelegate 中回调一下
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingImage:(UIImage *)image editingInfo:(nullable NSDictionary<NSString *,id> *)editingInfo NS_DEPRECATED_IOS(2_0, 3_0);
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary<NSString *,id> *)info;
- (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker;
只用第一个方法 拿到image就好了~