Description
提bug前必看
请先回答下列三个问题,否则不允处理,谢谢配合。
1、我最新的Demo是否有这个bug?【如果Demo没问题,请升级新版】
答:不好复现
2、你用的是什么版本?升级到最新版后是否正常?
答: 3.8.
3、是否有改动过我库内部的代码?【如有,请说明改动点】
答:没有
bug内容描述
Fatal Exception: NSInternalInconsistencyException
致命异常: NSInternalInconsistencyException
Attempted to scroll the collection view to an out-of-bounds item (1017) when there are only 1017 items in section 0. Collection view: <TZCollectionView: 0x117d7dc00; baseClass = UICollectionView; frame = (0 92; 414 720); clipsToBounds = YES; hidden = YES; gestureRecognizers = <NSArray: 0x1690a25b0>; backgroundColor = <UIDynamicSystemColor: 0x117d683c0; name = tertiarySystemBackgroundColor>; layer = <CALayer: 0x1691f9400>; contentOffset: {0, 0}; contentSize: {404, 26068.75}; adjustedContentInset: {5, 5, 5, 5}; layout: <TZRTLLayout: 0x157e4af80>; dataSource: <TZPhotoPickerController: 0x125e28f00>>.
尝试将集合视图滚动到超出范围的项(1017)时,section 0 中只有 1017 项。集合视图: <TZCollectionView: 0x117d7dc00; baseClass = UICollectionView; frame = (0 92; 414 720); clipsToBounds = YES; hidden = YES; gestureRecognizers = <NSArray: 0x1690a25b0>; backgroundColor = <UIDynamicSystemColor: 0x117d683c0; name = tertiarySystemBackgroundColor>; layer = <CALayer: 0x1691f9400>; contentOffset: {0, 0}; contentSize: {404, 26068.75}; adjustedContentInset: {5, 5, 5, 5}; layout: <TZRTLLayout: 0x157e4af80>; dataSource: <TZPhotoPickerController: 0x125e28f00>>。
我如何复现这个bug?
不容易复现
截图
无
其它说明
有没有其它要补充的?比如你的初始化TZImagePickerController的代码
相关信息:
iOS18.5.0
iPhone11
未越狱
屏幕方向:纵向
可用 RAM: 368.67 MB
看了一下内部的代码:
TZPhotoPickerController.m 中 969行~978 行
- (void)scrollCollectionViewToBottom {
TZImagePickerController *tzImagePickerVc = (TZImagePickerController *)self.navigationController;
NSInteger item = 0;
if (tzImagePickerVc.sortAscendingByModificationDate) {
item = [self getAllCellCount] - 1;
}
[self->_collectionView scrollToItemAtIndexPath:[NSIndexPath indexPathForItem:item inSection:0] atScrollPosition:UICollectionViewScrollPositionBottom animated:NO];
self->_shouldScrollToBottom = NO;
self->_collectionView.hidden = NO;
}
上述方法中的这个方法出现的问题
[self->_collectionView scrollToItemAtIndexPath:[NSIndexPath indexPathForItem:item inSection:0] atScrollPosition:UICollectionViewScrollPositionBottom animated:NO];
我现在简单的处理(我猜测的)
设置sortAscendingByModificationDate为 NO了, 这样item 就是 0 了,不会出现越界的问题了