YBImageBrowser icon indicating copy to clipboard operation
YBImageBrowser copied to clipboard

崩溃

Open leeqiangzi opened this issue 1 year ago • 5 comments

[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; }

leeqiangzi avatar Aug 22 '23 09:08 leeqiangzi

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

Pledge-WX avatar Sep 27 '23 01:09 Pledge-WX

可以手动改一下:

    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

RITL avatar Sep 27 '23 09:09 RITL

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

LBG-lbg avatar Nov 15 '23 04:11 LBG-lbg

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

LBG-lbg avatar Nov 15 '23 04:11 LBG-lbg

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

QiuYeHong90 avatar Nov 24 '23 11:11 QiuYeHong90