你怎么能访问UIImagePickerControllerMediaMetatdata?

时间:2014-03-25 11:23:06

标签: ios objective-c uiimagepickercontroller

我收到的信息字典看起来有点像这样:

UIImagePickerControllerMediaMetadata =     {
        DPIHeight = 72;
        DPIWidth = 72;
        Orientation = 1;
        "{Exif}" =         {
            ApertureValue = "2.526068811667588";
            BrightnessValue = "-0.1108180525441177";
            ColorSpace = 1;
            DateTimeDigitized = "2014:03:26 00:19:41";
            DateTimeOriginal = "2014:03:26 00:19:41";
            ExposureMode = 0;
            ExposureProgram = 2;
            ExposureTime = "0.06666666666666667";
            FNumber = "2.4";
            Flash = 32;
            FocalLenIn35mmFilm = 35;
            FocalLength = "4.28";
            ISOSpeedRatings =             (
                640
            );
            LensMake = Apple;
            LensModel = "iPad back camera 4.28mm f/2.4";

我想知道如何将DateTimeDigitized转换为NSString?这就是我试过的

NSDictionary *dataDict = [info objectForKey:@"Exif"];
NSString *dateString = [dataDict objectForKey:@"DateTimeDigitized"];
NSLog(@"%@ %@", dateString, [dataDict objectForKey:@"DateTimeDigitized"]);

但是一切都回来了。

1 个答案:

答案 0 :(得分:0)

您已跳过字典中的第一个键 - UIImagePickerControllerMediaMetadata。

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
    NSString* dateString = [[[info objectForKey:UIImagePickerControllerMediaMetadata] objectForKey:@"{Exif}"] objectForKey:@"DateTimeDigitized"];
    NSLog(@"%@", dateString);
}