【问题标题】:Disappearing Thumbnails消失的缩略图
【发布时间】:2012-08-17 19:58:07
【问题描述】:

在我的应用程序中,我注意到我正在保存的图像已开始写入相册并在照片应用程序中正确显示。但是,当我删除从中复制新图像的图像时,新图像的缩略图消失了。真的很奇怪。

这是我用来创建 CGImageRef 以保存到资产库的代码:

NSDictionary *options = [NSDictionary
    dictionaryWithObjectsAndKeys:(__bridge NSNumber *)kCFBooleanTrue,
            (__bridge NSString *)kCGImageSourceCreateThumbnailFromImageAlways, nil];
CGImageRef fullImage = [asset.defaultRepresentation CGImageWithOptions:options];

在我只是抓取 defaultRepresentation.fullResolution 图像并将其写入资产库之前。

我的问题是:通过这种方式保存图像,是否可以创建我期望的缩略图?如果不是,我是否应该做一些不同的事情来创建我的缩略图,这样它们就不会“消失”。

编辑: 发生这种情况时控制台中的错误是:

Aug 18 11:08:27 [phone name] [app name][2081] <Error>: Fixing thumbnail for 0x112b2dc0 <x-coredata://97C87589-EC35-4664-BE0D-AD01687EF7C4/Asset/p3637> AF6CD736-EF5D-482A-AFAD-F12834C301BF at index 2

缩略图修复失败似乎只发生在我使用新坐标修改 GPS 字典的图像上。我删除坐标的图像已正确修复缩略图。

这是我该部分的代码:

NSDictionary *gpsDictionary =
    [readOnlyMetadata valueForKey:(__bridge NSString*) kCGImagePropertyGPSDictionary];
NSMutableDictionary *modifiableGpsDictionary = (gpsDictionary) ?
    [gpsDictionary mutableCopy] : [[NSMutableDictionary alloc] init];
        CLLocationCoordinate2D coordinate = thumbnail.coordinate;

[modifiableGpsDictionary setValue:[NSNumber numberWithDouble:ABS(coordinate.latitude)]
    forKey:(__bridge NSString*) kCGImagePropertyGPSLatitude];
[modifiableGpsDictionary setValue:(coordinate.latitude < 0.0) ? @"S" : @"N"
    forKey:(__bridge NSString*) kCGImagePropertyGPSLatitudeRef];
[modifiableGpsDictionary setValue:[NSNumber numberWithDouble:ABS(coordinate.longitude)]
    forKey:(__bridge NSString*) kCGImagePropertyGPSLongitude];
[modifiableGpsDictionary setValue:(coordinate.longitude < 0.0) ? @"W" : @"E"
    forKey:(__bridge NSString*) kCGImagePropertyGPSLongitudeRef];

[modifiableMetadata setValue:modifiableGpsDictionary
    forKey:(__bridge NSString*) kCGImagePropertyGPSDictionary];

【问题讨论】:

    标签: ios alassetslibrary assetslibrary


    【解决方案1】:

    原来我在没有现有字典的情况下将 GPS 数据添加到图像的方式是问题所在:

    Saving Geotag info with photo on iOS4.1

    【讨论】:

      猜你喜欢
      • 2013-05-23
      • 2012-04-10
      • 2021-11-04
      • 1970-01-01
      • 2018-08-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多