From aabefbd36b356b055f38c131aaab24993e270bba Mon Sep 17 00:00:00 2001 From: dmcBig Date: Wed, 8 Aug 2018 10:36:32 +0800 Subject: [PATCH] fix bug --- src/ios/DMCMediaPicker/AlbumListView.m | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/ios/DMCMediaPicker/AlbumListView.m b/src/ios/DMCMediaPicker/AlbumListView.m index b51d80e..2590635 100644 --- a/src/ios/DMCMediaPicker/AlbumListView.m +++ b/src/ios/DMCMediaPicker/AlbumListView.m @@ -49,12 +49,15 @@ _nowIndex=nowIndex; [self.tableView reloadData]; int scrolltoIndex=0; + //下面代码是让下拉选中了有个居中的感觉 if((int)_nowIndex>[_dataNameSource count]-4){ scrolltoIndex= [_dataNameSource count]-1; }else{ scrolltoIndex=((int)_nowIndex+3); } - [self.tableView scrollToRowAtIndexPath:[NSIndexPath indexPathForItem:scrolltoIndex inSection:0] atScrollPosition:UITableViewScrollPositionBottom animated:NO]; + if([_dataNameSource count]>3){ + [self.tableView scrollToRowAtIndexPath:[NSIndexPath indexPathForItem:scrolltoIndex inSection:0] atScrollPosition:UITableViewScrollPositionBottom animated:NO]; + } } @@ -103,7 +106,7 @@ options:nil resultHandler:^(UIImage * _Nullable result, NSDictionary * _Nullable info) { UIImageView *cellImageView = (UIImageView *)[cell viewWithTag:101]; - + cellImageView.image = result; //标题 UILabel *cellText = (UILabel *)[cell viewWithTag:102]; @@ -115,9 +118,9 @@ [attrStr addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:12] range:[str rangeOfString:count]]; cellText.attributedText =attrStr; - + }]; - + return cell; } @@ -147,4 +150,4 @@ } -@end +@end \ No newline at end of file