500px技术周报008
概览
目前APP的相册界面有两个问题:1、airdrop传过来的照片没有在最前面 2、照片在上万张的情况下容易闪退。
问题描述
代码中使用creationDate排序,如果不使用creationDate排序则是倒序,最早的在前面
self.fetchOptions = [PHFetchOptions new];
self.fetchOptions.predicate = [NSPredicate predicateWithFormat:@"mediaType = %i", PHAssetMediaTypeImage];
self.fetchOptions.sortDescriptors = @[[NSSortDescriptor sortDescriptorWithKey:@"creationDate" ascending:NO]];
解决方案
去掉代码中使用creationDate排序
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
PHAsset *asset = self.assetFetchResults[self.assetFetchResults.count-indexPath.item];
}
那么在微信和QQ是如何来实现的?请看下图
可以看到都是使用uitableview,每个cell里有四个等比例图,默认进入到列表的最下面。
微博和图虫
两者都使用的是uicollectionview,默认进入列表的最上端
Written on November 17, 2017