0
我有一個奇怪的問題,試圖使用ALAssetsLibrary將圖像保存到我的SavedPhotosAlbum,特別是當我使用writeImageToSavedPhotosAlbum方法時。ALAsset NSURL * assetURL返回NULL
基本上我的問題是,NSURL在我的完成塊中返回null ...沒有錯誤,但URL爲空。
這裏的方法:
UIImage *imageToSave = [libraryPicture imageFromCurrentlyProcessedOutput];
ALAssetsLibrary *library = [[ALAssetsLibrary alloc] init];
[library writeImageToSavedPhotosAlbum:[imageToSave CGImage] orientation:ALAssetOrientationUp completionBlock:^(NSURL *assetURL, NSError *error) {
NSLog(@"AssetURL: %@", assetURL);
if(!error) {
NSLog(@"\t ! Error");
NSLog(@"\t Error: %@", [error localizedDescription]);
NSLog(@"\t Error code %d", [error code]);
}
if(error != nil) {
NSLog(@"\t ERROR != NIL");
NSLog(@"\t Error - Image Failed To Save With Error: %@", [error localizedDescription]);
NSLog(@"\t Error code %d", [error code]);
}
if(error == nil) {
NSLog(@"\t ERROR == NIL");
}
}];
我用一個非常類似的方法只需要幾行遠(在另一臺交換機的情況下)的作品,並打印出幾乎相同完成塊內的URL(雖然叫方法不同):
[stillCamera capturePhotoAsJPEGProcessedUpToFilter:selectedFilter withCompletionHandler:^(NSData *processedJPEG, NSError *error) {
ALAssetsLibrary *library = [[ALAssetsLibrary alloc] init];
[library writeImageDataToSavedPhotosAlbum:processedJPEG metadata:stillCamera.currentCaptureMetadata completionBlock:^(NSURL *assetURL, NSError *error2) {
if (error2 != nil) {
NSLog(@"ERROR: the image failed to be written");
}
else {
NSLog(@"PHOTO SAVED FROM STILL CAMERA - assetURL: %@", assetURL);
}
}];
}];
嗯,謝謝麥克。我會研究它並報告回去...... –