【问题标题】:iOS8 Photo Extension says Unable to save changesiOS8 照片扩展说无法保存更改
【发布时间】:2015-06-23 20:24:04
【问题描述】:

我正在尝试创建一个压缩图像的 iOS 照片扩展,这是 finishContentEditingWithCompletionHandler 函数:

func finishContentEditingWithCompletionHandler(completionHandler: ((PHContentEditingOutput!) -> Void)!) {        
    dispatch_async(dispatch_get_global_queue(CLong(DISPATCH_QUEUE_PRIORITY_DEFAULT), 0)) {
      atomically: true)


        let url = self.input?.fullSizeImageURL

        if let imageUrl = url {
            var fullImage = UIImage(contentsOfFile:
                imageUrl.path!)
            //Just compresses the image
            let renderedJPEGData =
            UIImageJPEGRepresentation(fullImage, self.comprestionRatioFloat)
            var currentFilter = "FakeFilter"

            renderedJPEGData.writeToURL(
                output.renderedContentURL,
                atomically: true)
            let archivedData =
            NSKeyedArchiver.archivedDataWithRootObject(
                currentFilter)
            output.adjustmentData = PHAdjustmentData(formatIdentifier:"MyApp.Ext", formatVersion:"1.0", data:archivedData)

            }

        completionHandler?(output)

        // Clean up temporary files, etc.
    }
}

当我在设备上测试它时显示“无法保存更改”,有什么问题吗?

【问题讨论】:

    标签: swift ios8-extension


    【解决方案1】:

    最后我发现这是因为输出图像与输入图像几乎相同。稍微缩小输出图像可以解决问题。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2014-12-09
      • 2019-02-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多