iOS: 如何使用photos Framework (iOS 8.0)?
iOS: How to use photos Framework (iOS 8.0)?
如何使用照片Framework (iOS 8.0)
?我想要一个可以在 UICollectionView
.
中一张一张显示的结果
如果你想要一个包含所有图片的fetchResult,你可以这样解决:
// Property in your UICollectionViewController.h file
@property (strong, nonatomic) PHFetchResult *allPhotosFetchResult;
// In your awakeFromNib or where you refresh your Data
PHFetchOptions *allPhotosOptions = [PHFetchOptions new];
allPhotosOptions.sortDescriptors = @[[NSSortDescriptor sortDescriptorWithKey:@"creationDate" ascending:NO]];
self.allPhotosFetchResult = [PHAsset fetchAssetsWithMediaType:PHAssetMediaTypeImage options:allPhotosOptions];
在您的 collectionView:cellForItemAtIndexPath: 方法中,您可以使用
访问资产
self.allPhotosFetchResult[indexPath.row];
获取collectionView:numberOfItemsInSection中的行数:
self.allPhotosFetchResult.count
如何使用照片Framework (iOS 8.0)
?我想要一个可以在 UICollectionView
.
如果你想要一个包含所有图片的fetchResult,你可以这样解决:
// Property in your UICollectionViewController.h file
@property (strong, nonatomic) PHFetchResult *allPhotosFetchResult;
// In your awakeFromNib or where you refresh your Data
PHFetchOptions *allPhotosOptions = [PHFetchOptions new];
allPhotosOptions.sortDescriptors = @[[NSSortDescriptor sortDescriptorWithKey:@"creationDate" ascending:NO]];
self.allPhotosFetchResult = [PHAsset fetchAssetsWithMediaType:PHAssetMediaTypeImage options:allPhotosOptions];
在您的 collectionView:cellForItemAtIndexPath: 方法中,您可以使用
访问资产self.allPhotosFetchResult[indexPath.row];
获取collectionView:numberOfItemsInSection中的行数:
self.allPhotosFetchResult.count