KNPhotoBrowser.m:730
-[KNPhotoBrowser photoBrowserWillShowWithAnimated] + 730
KNPhotoBrowser.m:1116
-[KNPhotoBrowser layoutCollectionViewAndLayout] + 1116
KNPhotoBrowser.m:1080
-[KNPhotoBrowser viewWillLayoutSubviews] + 1080
线上用户有些崩溃,但是没复现到。
KNPhotoItems *items = _itemsArr[_currentIndex];
看堆栈是730行中的 _currentIndex是-1,NSArray的objectAtIndex再把它转成NSUInteger,就变成了18446744073709551615。
问题在于,没看到哪里把它变成-1。
下面是业务层调用KNPhotoBrowser的方法。目前调用的地方传过来的photos只会有1个元素,所以_currentIndex没有外部设置,按默认来说应该一直是0.
-
(void)showWithPhotos:(NSArray<NSString *> *)photos sourceView:(UIView *__nullable)sourceView {
NSMutableArray *array = [NSMutableArray array];
for (NSString *url in photos) {
KNPhotoItems *items = [[KNPhotoItems alloc] init];
items.url = url;
items.sourceView = sourceView;
}
KNPhotoBrowser *photoBrowser = [[KNPhotoBrowser alloc] init];
photoBrowser.itemsArr = [array copy];
[photoBrowser present];
}
KNPhotoBrowser.m:730
-[KNPhotoBrowser photoBrowserWillShowWithAnimated] + 730
KNPhotoBrowser.m:1116
-[KNPhotoBrowser layoutCollectionViewAndLayout] + 1116
KNPhotoBrowser.m:1080
-[KNPhotoBrowser viewWillLayoutSubviews] + 1080
线上用户有些崩溃,但是没复现到。
KNPhotoItems *items = _itemsArr[_currentIndex];
看堆栈是730行中的 _currentIndex是-1,NSArray的objectAtIndex再把它转成NSUInteger,就变成了18446744073709551615。
问题在于,没看到哪里把它变成-1。
下面是业务层调用KNPhotoBrowser的方法。目前调用的地方传过来的photos只会有1个元素,所以_currentIndex没有外部设置,按默认来说应该一直是0.
(void)showWithPhotos:(NSArray<NSString *> *)photos sourceView:(UIView *__nullable)sourceView {
NSMutableArray *array = [NSMutableArray array];
for (NSString *url in photos) {
KNPhotoItems *items = [[KNPhotoItems alloc] init];
items.url = url;
items.sourceView = sourceView;
}
KNPhotoBrowser *photoBrowser = [[KNPhotoBrowser alloc] init];
photoBrowser.itemsArr = [array copy];
[photoBrowser present];
}