3
我試圖將圖像從相機保存到照片庫,然後存儲保存的圖像的URL。我的代碼:將圖像保存到照片庫並獲取保存的圖像的URL
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
ALAssetsLibrary *library = [[ALAssetsLibrary alloc]init];
[library writeImageToSavedPhotosAlbum:(__bridge CGImageRef)([info objectForKey:UIImagePickerControllerOriginalImage])
orientation:ALAssetOrientationUp completionBlock:^(NSURL *assetURL, NSError *error) {
if(error == nil) {
_myImageUrl = [NSString stringWithFormat:@"%@",assetURL];
NSLog(@"%@",assetURL);
} else NSLog(@"%@",error);
}];
[picker dismissViewControllerAnimated:YES completion:nil];}
我的問題是,assetUrl始終爲NULL。有任何想法嗎? 謝謝!
可能與本文相關。可能是iOS7的錯誤。 [ALAssetsLibraryWriteVideoCompletionBlock返回未定義的值] [1] [1]:http://stackoverflow.com/questions/20813540/alassetslibrarywritevideocompletionblock-return-undefined-values – GregP