Skip to content

ios17点击查看图片崩溃 #356

Open
@wydgithub

Description

Description

调用方法
YBIBImageData *ybData = [YBIBImageData new];
ybData.imageURL = [NSURL URLWithString:urlString];
ybData.projectiveView = nil;
YBImageBrowser *browser = [YBImageBrowser new];
browser.dataSourceArray = @[ybData];
browser.currentPage = 0;
[browser show];

崩溃的地方
UIImage *YBIBSnapshotView(UIView *view) {
UIGraphicsBeginImageContextWithOptions(view.bounds.size, YES, [UIScreen mainScreen].scale);
[view drawViewHierarchyInRect:view.bounds afterScreenUpdates:NO];
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return image;
}

建议:
UIImage *YBIBSnapshotView(UIView *view) {
//这里加上
if(![view isKindOfClass:UIView.class] || view.bounds.size.width<=1||view.bounds.size.height<=1){
return UIImage.new;
}
UIGraphicsBeginImageContextWithOptions(view.bounds.size, YES, [UIScreen mainScreen].scale);
[view drawViewHierarchyInRect:view.bounds afterScreenUpdates:NO];
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return image;
}

Environment

  • YBImageBrowser version:3.0.9
  • iOS version:ios17

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions