indulgeIn / YBImageBrowser

iOS image browser / iOS 图片浏览器 (支持视频)
MIT License
2.37k stars 472 forks source link

崩溃 #352

Open leeqiangzi opened 1 year ago

leeqiangzi commented 1 year ago

[Unknown process name] CGBitmapContextCreateImage: invalid context 0x281fa4cc0. If you want to see the backtrace, please set CG_CONTEXT_SHOW_BACKTRACE environmental variable.

断点崩溃在该方法中: UIImage YBIBSnapshotView(UIView view) { UIGraphicsBeginImageContextWithOptions(view.bounds.size, YES, [UIScreen mainScreen].scale); [view drawViewHierarchyInRect:view.bounds afterScreenUpdates:NO]; UIImage *image = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); // crash it return image; }

Pledge-WX commented 11 months ago

在iOS17中UIGraphicsBeginImageContextWithOptions已经被废弃了,这个作者应该已经不更新了吧!我准备换掉

RITL commented 11 months ago

可以手动改一下:

    UIGraphicsImageRendererFormat *format = [[UIGraphicsImageRendererFormat alloc] init];
    format.opaque = YES;
    format.scale = [UIScreen mainScreen].scale;

    UIGraphicsImageRenderer *renderer = [[UIGraphicsImageRenderer alloc] initWithSize:view.bounds.size format:format];
    UIImage *image = [renderer imageWithActions:^(UIGraphicsImageRendererContext * _Nonnull rendererContext) {
            [view drawViewHierarchyInRect:view.bounds afterScreenUpdates:NO];
    }];

@leeqiangzi

LBG-lbg commented 10 months ago

判断一下 CGSizeEqualToSize(view.bounds.size, CGSizeZero)

LBG-lbg commented 10 months ago

最好拉个分支 自己改 自己pod自己的分支,这次iOS17 要改的第三方很多

QiuYeHong90 commented 9 months ago

https://github.com/QiuYeHong90/YBImageBrowser 可以关注我修复的仓库 我解决了一些bug 和 ui 的问题, 欢迎提issue