如何使用全屏图像ios创建自定义UIImagePickerController [英] How to create a custom UIImagePickerController with full-screen images ios

查看:115
本文介绍了如何使用全屏图像ios创建自定义UIImagePickerController的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个简单的UIImagePickerController,它将使用相机拍照,但我想要它做几件事:

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:


  • 拥有自定义相机用户界面

  • 使用全屏而不是480x640(如果使用4英寸手机)

这是我展示UIImagePickerController的代码:

Here is my code for showing the UIImagePickerController:

- (IBAction)pick:(id)sender {
    NSLog(@"abc");
    picker = [[UIImagePickerController alloc] init];
    if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) {
        [picker setSourceType:UIImagePickerControllerSourceTypeCamera];
    } else {
        [picker setSourceType:UIImagePickerControllerSourceTypePhotoLibrary];
    }
    [picker setDelegate:self];
    [self presentViewController:picker animated:YES completion:nil];

}

这里是拍摄图像的时间:

and here is for when the image gets taken:

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

我该怎么做?

谢谢

推荐答案

对于第一个要点,我想你可以使用 cameraOverlayView UIImagePickerController 对象的属性,用于在选择器默认界面上添加自定义UI:

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

}

编辑

我测试了 UIImagePickerController ,它返回带有全尺寸图像(PixelXDimension和PixelYDimension):

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

编辑

此外,您可以设置图像视图的内容模式以调整大小并适合容器视图:

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];
}

然后适合 imageView 根据您的需要,您可以使用自动布局自动调整大小来查看设备屏幕(4英寸与否) C $ C>。

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.

这篇关于如何使用全屏图像ios创建自定义UIImagePickerController的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆