【发布时间】:2014-12-22 22:02:06
【问题描述】:
如果图片从相册加载到应用程序中,如何获得该图片的日期显示在应用程序上,如下面的屏幕截图所示?
【问题讨论】:
标签: objective-c xcode uiimageview uiimage alassetslibrary
如果图片从相册加载到应用程序中,如何获得该图片的日期显示在应用程序上,如下面的屏幕截图所示?
【问题讨论】:
标签: objective-c xcode uiimageview uiimage alassetslibrary
您可以使用ALAsset library,它包含名为ALAssetPropertyDate 的属性。因此,您可以使用它来获取如下日期:-
NSURL *url = @"your url";
ALAssetsLibrary* assetslibrary = [[ALAssetsLibrary alloc] init];
[assetslibrary assetForURL:url
resultBlock:^(ALAsset *asset) {
NSDate *myDate = [asset valueForProperty:ALAssetPropertyDate];
NSLog(@"Date: %@", myDate);
} failureBlock:^(NSError *error) {
NSLog(@"Error");
}];
【讨论】: