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

YYTextEffectWindow hideMagnifier隐藏放大镜很容易崩溃 #963

Open
rome753 opened this issue Oct 18, 2021 · 1 comment
Open

YYTextEffectWindow hideMagnifier隐藏放大镜很容易崩溃 #963

rome753 opened this issue Oct 18, 2021 · 1 comment

Comments

@rome753
Copy link

rome753 commented Oct 18, 2021

你好,使用YYTextView,输入多行后选择文本时会偶现崩溃,出现在YYTextEffectWindow类的这个方法里

  • (CGFloat)_updateMagnifier:(YYTextMagnifier *)mag {
    ...
    for (UIWindow *window in windows) {
    if (window.hidden || window.alpha <= 0.01) continue;
    if (window.screen != mainScreen) continue;
    if ([window isKindOfClass:self.class]) break; //don't capture window above self
    CGContextSaveGState(context);
    CGContextConcatCTM(context, YYTextCGAffineTransformGetFromViews(window, self));
    [window.layer renderInContext:context]; //render ///Thread 1: EXC_BAD_ACCESS (code=1, address=0x9cd19f560)
    //[window drawViewHierarchyInRect:window.bounds afterScreenUpdates:NO]; //slower when capture whole window
    CGContextRestoreGState(context);
    }
    ...
    }

机型6s,系统14.2

@rome753
Copy link
Author

rome753 commented Oct 18, 2021

页面有右滑退出,页面刚创建(没有文本)马上按YYTextView显示放大镜,然后往右拖动,基本必现崩溃。建议加个不显示放大镜的方法。

在上面崩溃的代码前添加如下判断也可以解决问题
if ([window.layer respondsToSelector:@selector(renderInContext)] == NO) {
NSLog(@"window layer被释放了");
break;
}

@rome753 rome753 changed the title hideMagnifier隐藏放大镜有偶现崩溃 YYTextEffectWindow hideMagnifier隐藏放大镜很容易崩溃 Oct 18, 2021
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