Getting image from UIImagePickerController

后端 未结 4 1152
半阙折子戏
半阙折子戏 2021-02-15 04:11

I want to get the image frm imagepickercontroller.But my code doesn\'t have any effect Here is the code..

- (void)imagePickerController:(UIImagePick         


        
相关标签:
4条回答
  • 2021-02-15 04:20

    Updated for Swift 5, the following will safely unwrap the UIImage.

    // This uses the full key value
    guard let image = info[UIImagePickerController.InfoKey.originalImage] as? UIImage else { return }
    
    // This uses only the info key value for shorter code
    guard let image = info[.originalImage] as? UIImage else { return }
    
    0 讨论(0)
  • 2021-02-15 04:27

    Try

    imageview.image = (UIImage*) [info objectForKey:UIImagePickerControllerOriginalImage];
    
    0 讨论(0)
  • 2021-02-15 04:37

    just try this

    imageview.image = [info objectForKey:UIImagePickerControllerOriginalImage];
    
    0 讨论(0)
  • 2021-02-15 04:43

    You can try this code to access an Image returned from the picker

    - (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
    
        [picker dismissModalViewControllerAnimated:YES];
    
        UIImage* originalImage = nil;
        originalImage = [info objectForKey:UIImagePickerControllerEditedImage];
        if(originalImage==nil)
        {
            originalImage = [info objectForKey:UIImagePickerControllerOriginalImage];
        }
        if(originalImage==nil)
        {
            originalImage = [info objectForKey:UIImagePickerControllerCropRect];
        }
      //At this point you have the selected image in originalImage
        [self saveImageToDocumentDirectory:originalImage];
    }
    
    0 讨论(0)
提交回复
热议问题