SDPhotoBrowser
SDPhotoBrowser copied to clipboard
点击下标超过5的时候会报一个数组下标超标的错误[__NSArrayM objectAtIndex:]: index 7 beyond bounds [0 .. 4]'...你的subviews只创建了5个好像
错误方法在这 ...好像不好改的样子
- (void)showFirstImage { UIView *sourceView = self.sourceImagesContainerView.subviews[self.currentImageIndex]; CGRect rect = [self.sourceImagesContainerView convertRect:sourceView.frame toView:self]; ....
// 因为等着上线就测了下 发现了问题的地方 已经改了但是git提交不上去 // 第一个地方
-
(void)photoClick:(UITapGestureRecognizer *)recognizer { _scrollView.hidden = YES;
SDBrowserImageView *currentImageView = (SDBrowserImageView *)recognizer.view; NSInteger currentIndex = currentImageView.tag;
/**
- sourceImagesContainerView 的子控件只有5个 如果下标超过4就会取值报错,我测了下你这个subview的作用好像是做效果用的 所以最好是模一下subViews.count,下同 一个应该是打开效果一个是收缩效果。望采纳,个人觉得给个随机数比较好,效果随机 如果取模的话每个index的效果就固定了 */ UIView *sourceView = self.sourceImagesContainerView.subviews[currentIndex % self.sourceImagesContainerView.subviews.count]; CGRect targetTemp = [self.sourceImagesContainerView convertRect:sourceView.frame toView:self];
// 第二个地方
- (void)showFirstImage
{
/**
- sourceImagesContainerView 的子控件只有5个 如果下标超过4就会取值报错,我测了下你这个subview的作用好像是做效果用的 所以最好是模一下subViews.count */ UIView *sourceView = self.sourceImagesContainerView.subviews[self.currentImageIndex % self.sourceImagesContainerView.subviews.count]; CGRect rect = [self.sourceImagesContainerView convertRect:sourceView.frame toView:self];