0
ALAssetLibrary可以非常容易地從相機膠捲或相冊中獲取圖像文件信息。但是,當我嘗試使用它來加載Document文件夾(沙箱)中的圖像文件時,它始終沒有任何結果。這是我的代碼:ALAssetLibrary可以在Document文件夾中加載圖像文件嗎?
//Get full file path in the Document folder.(Yes, IMG001.jpg exists in that place)
NSArray* paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString* theFileName = [[paths objectAtIndex:0] stringByAppendingPathComponent:@"IMG001.jpg"];
NSURL* theFileURL = [NSURL fileURLWithPath:theFileName];
//Now try to load the asset.
ALAssetsLibrary *library = [[ALAssetsLibrary alloc] init];
[library assetForURL:theFileURL resultBlock:^(ALAsset *asset) {
//asset here is always nil.
} failureBlock:^(NSError *error) {
//it does not run in this place.
}];
有人可以告訴我爲什麼嗎?
感謝。但是UIImage不包含元數據。事實上,我的目的是通過元數據將我的照片保存到相機膠捲上。這可以通過ALAssetLibrary writeImageToSavedPhotosAlbum:metadata:completionBlock:的方法完成。所以,我的目標是元數據。我想通過ALAssetLibrary獲取元數據。 – guogangj 2015-03-13 07:05:52