Skip to content

Commit 6220d7f

Browse files
wanghenghengEase
authored and
Ease
committed
QBImagePickerController 还是模仿相册的 - 图片正序排列&滑动到底部
1 parent 974d235 commit 6220d7f

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

Coding_iOS/Vendor/QBImagePickerController/QBAssetsCollectionViewController.m

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ @interface QBAssetsCollectionViewController ()
2020
@property (nonatomic, assign) NSUInteger numberOfPhotos;
2121
@property (nonatomic, assign) NSUInteger numberOfVideos;
2222

23-
@property (nonatomic, assign) BOOL disableScrollToBottom;
23+
@property (nonatomic, assign) BOOL disableScrollToBottom, appearToShow;
2424

2525
@end
2626

@@ -52,6 +52,7 @@ - (void)viewWillAppear:(BOOL)animated
5252
if (self.allowsMultipleSelection) {
5353
self.navigationItem.rightBarButtonItem.enabled = [self validateNumberOfSelections:self.imagePickerController.selectedAssetURLs.count];
5454
}
55+
_appearToShow = YES;
5556
}
5657

5758
- (void)viewWillDisappear:(BOOL)animated
@@ -68,6 +69,14 @@ - (void)viewDidDisappear:(BOOL)animated
6869
self.disableScrollToBottom = NO;
6970
}
7071

72+
- (void)viewDidLayoutSubviews{
73+
[super viewDidLayoutSubviews];
74+
if (_appearToShow) {
75+
[self.collectionView scrollToItemAtIndexPath:[NSIndexPath indexPathForRow:self.numberOfAssets-1 inSection:0] atScrollPosition:UICollectionViewScrollPositionTop animated:NO];
76+
_appearToShow = NO;
77+
}
78+
}
79+
7180

7281
#pragma mark - Accessors
7382

@@ -211,7 +220,7 @@ - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cell
211220
QBAssetsCollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"AssetsCell" forIndexPath:indexPath];
212221
cell.showsOverlayViewWhenSelected = self.allowsMultipleSelection;
213222

214-
ALAsset *asset = self.assets[self.assets.count -1 - indexPath.row];
223+
ALAsset *asset = self.assets[indexPath.row];
215224
cell.asset = asset;
216225

217226
return cell;

0 commit comments

Comments
 (0)