我试图阻止iOS在用户编辑使用该应用拍摄的照片时显示以下对话框:
根据Apple的PHContentEditingOutput文档:
如果您的应用编辑了照片中已有资源的内容 您的应用最近添加的图书馆资源 - 照片 提示用户允许更改资产的内容。如果 相反,您的应用程序使用initWithPlaceholderForCreatedAsset:方法 要创建包含已编辑内容的资源,照片会识别您的应用 内容的所有权,因此不需要提示 用户获得许可进行编辑。
但是,我似乎总是得到权限对话框。这是将图片添加到照片库的代码:
var assetPlaceholder:PHObjectPlaceholder!
PHPhotoLibrary.sharedPhotoLibrary().performChanges({
let creationRequest = PHAssetCreationRequest.creationRequestForAssetFromImageAtFileURL(NSURL(fileURLWithPath: originalImagePath))
assetPlaceholder = creationRequest!.placeholderForCreatedAsset
let editingOutput = PHContentEditingOutput(placeholderForCreatedAsset: assetPlaceholder!)
editingOutput.adjustmentData = adjustmentData
imageData.writeToURL(editingOutput.renderedContentURL, atomically: true)
creationRequest!.contentEditingOutput = editingOutput
}, completionHandler: { (success:Bool, error: NSError?) in
handler(assetPlaceholder.localIdentifier, error)
})
编辑我使用的图片:
let inputOptions = PHContentEditingInputRequestOptions()
inputOptions.networkAccessAllowed = true
inputOptions.canHandleAdjustmentData = { adjustmentData in
return adjustmentData.formatIdentifier == thisAppFormatIdentifier
}
asset.requestContentEditingInputWithOptions(inputOptions, completionHandler: { ( editingInput, info) -> Void in
let editingOutput = PHContentEditingOutput(contentEditingInput: editingInput!)
PHPhotoLibrary.sharedPhotoLibrary().performChanges({
let changeRequest = PHAssetChangeRequest(forAsset: asset)
editingOutput.adjustmentData = adjustmentData
imageData.writeToURL(editingOutput.renderedContentURL, atomically: true)
changeRequest.contentEditingOutput = editingOutput
}, completionHandler: { (success:Bool, error: NSError?) in
handler(error)
})
})
这最后一部分总是触发系统对话框。我该怎么做才能阻止警报显示?