suchen

Heim  >  Fragen und Antworten  >  Hauptteil

ios - 在相册中选择一张图片,图片显示不出

@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
迷茫迷茫2771 Tage vor571

Antworte allen(1)Ich werde antworten

  • 怪我咯

    怪我咯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就好了~

    Antwort
    0
  • StornierenAntwort