Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

点击图片crash #44

Open
hxming2919 opened this issue Mar 6, 2017 · 0 comments
Open

点击图片crash #44

hxming2919 opened this issue Mar 6, 2017 · 0 comments

Comments

@hxming2919
Copy link

  • (void)photoClick:(UITapGestureRecognizer *)recognizer
    {
    _scrollView.hidden = YES;
    _willDisappear = YES;

    SDBrowserImageView *currentImageView = (SDBrowserImageView *)recognizer.view;
    NSInteger currentIndex = currentImageView.tag;

    UIView *sourceView = self.sourceImagesContainerView.subviews[currentIndex];
    CGRect targetTemp = [self.sourceImagesContainerView convertRect:sourceView.frame toView:self];

    UIImageView *tempView = [[UIImageView alloc] init];
    tempView.contentMode = sourceView.contentMode;
    tempView.clipsToBounds = YES;
    tempView.image = currentImageView.image;
    CGFloat h = (self.bounds.size.width / currentImageView.image.size.width) * currentImageView.image.size.height;

    if (!currentImageView.image) { // 防止 因imageview的image加载失败 导致 崩溃
    h = self.bounds.size.height;
    }

    tempView.bounds = CGRectMake(0, 0, self.bounds.size.width, h);
    tempView.center = self.center;

    [self addSubview:tempView];

    _saveButton.hidden = YES;

    [UIView animateWithDuration:SDPhotoBrowserHideImageAnimationDuration animations:^{
    tempView.frame = targetTemp;
    self.backgroundColor = [UIColor clearColor];
    _indexLabel.alpha = 0.1;
    } completion:^(BOOL finished) {
    [self removeFromSuperview];
    }];
    }

这里会导致crash
UIView *sourceView = self.sourceImagesContainerView.subviews[currentIndex];

场景:

sourceImagesContainerView的subviews的count 小于 图片数组的时候

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant