How to create a custom UIImagePickerController with full-screen images ios

前端 未结 1 741
有刺的猬
有刺的猬 2020-12-19 09:42

I have a simple UIImagePickerController which will use the camera to take a picture, but there are a couple things I would like it to do:

  • Have a custom camera
相关标签:
1条回答
  • 2020-12-19 10:34

    For the first bullet point I suppose that you could use the cameraOverlayView property of an UIImagePickerController object to add your custom UI over the picker default interface:

    - (IBAction)pick:(id)sender {
        NSLog(@"abc");
        picker = [[UIImagePickerController alloc] init];
        if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) {
            [picker setSourceType:UIImagePickerControllerSourceTypeCamera];
        } else {
            [picker setSourceType:UIImagePickerControllerSourceTypePhotoLibrary];
        }
    
        // Add here your custom UI here
        [picker setCameraOverlayView:self.customCameraOverlayView];
    
        [picker setDelegate:self];
        [self presentViewController:picker animated:YES completion:nil];
    
    }
    

    EDIT

    I've tested the UIImagePickerController and it returns the image with it's full dimensions (PixelXDimension and PixelYDimension):

     UIImagePickerControllerMediaMetadata =     {
            DPIHeight = 72;
            DPIWidth = 72;
            Orientation = 6;
            "{Exif}" =         {
                ApertureValue = "2.526068811667588";
                BrightnessValue = "-0.5779073354035674";
                ColorSpace = 1;
                DateTimeDigitized = "2013:04:07 22:30:03";
                DateTimeOriginal = "2013:04:07 22:30:03";
                ExposureMode = 0;
                ExposureProgram = 2;
                ExposureTime = "0.05882352941176471";
                FNumber = "2.4";
                Flash = 24;
                FocalLenIn35mmFilm = 35;
                FocalLength = "4.28";
                ISOSpeedRatings =             (
                    800
                );
                MeteringMode = 3;
                PixelXDimension = 3264;
                PixelYDimension = 2448;
                SceneType = 1;
                SensingMethod = 2;
                ShutterSpeedValue = "4.058893689053568";
                SubjectArea =             (
                    1874,
                    1478,
                    610,
                    612
                );
                WhiteBalance = 0;
            };
            "{TIFF}" =         {
                DateTime = "2013:04:07 22:30:03";
                Make = Apple;
                Model = "iPhone 4S";
                Software = "6.1.3";
                XResolution = 72;
                YResolution = 72;
            };
        };
    

    EDIT

    Also you could set to your image view the content mode to resize and fit the container view:

    - (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
        [self dismissViewControllerAnimated:YES completion:nil];
        UIImage *image = [info objectForKey:UIImagePickerControllerOriginalImage];
        [imageView setContentMode:UIViewContentModeScaleAspectFill];
        [imageView setImage:image];
    }
    

    and after that to fit the imageView as you need in you view controller taking in consideration the device screen (4inch or not) using auto layout or auto sizing.

    0 讨论(0)
提交回复
热议问题