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

iOS7下YYtextView插入YYImage Crash #261

Closed
mayazhe opened this issue Apr 1, 2016 · 1 comment
Closed

iOS7下YYtextView插入YYImage Crash #261

mayazhe opened this issue Apr 1, 2016 · 1 comment

Comments

@mayazhe
Copy link

mayazhe commented Apr 1, 2016

YYtextView插入YYImage 崩溃,目前只在iOS7发现有此问题

我的代码,运行到最后一句崩溃:

YYImage *image = [[YYImage alloc] initWithCGImage:[[asset defaultRepresentation] fullScreenImage]];
DGCloseImageView *imageView = [[DGCloseImageView alloc] initWithImage:image];
imageView.url = ast.url;
imageView.delegate = self;

CGFloat width = kScreenWidth - 8*2;
CGFloat height = image.size.height * width / image.size.width;
CGSize size = CGSizeMake(width, height);

NSMutableAttributedString *attachText = [NSMutableAttributedString yy_attachmentStringWithContent:imageView contentMode:UIViewContentModeScaleAspectFill attachmentSize:size alignToFont:KFont alignment:YYTextVerticalAlignmentCenter];

attachText.yy_font = KFont;
attachText.yy_minimumLineHeight = 30;
[attachText yy_insertString:@"\n" atIndex:0];
[attachText yy_appendString:@"\n"];

NSRange range = _textView.selectedRange;
NSMutableAttributedString *attr = [[NSMutableAttributedString alloc] initWithAttributedString:_textView.attributedText];
[attr insertAttributedString:attachText atIndex:range.location];
_textView.attributedText = attr;

崩溃在 YYTextEffectWindow.m 文件如下代码:

CGPoint center = [dot yy_convertPoint:CGPointMake(CGRectGetWidth(dot.frame) / 2, CGRectGetHeight(dot.frame) / 2) toViewOrWindow:self];
dot.mirror.center = center;

应该是计算出来的frame有问题:
center = (x = NaN, y = NaN)

aaa

ibireme added a commit that referenced this issue Apr 2, 2016
@ibireme
Copy link
Owner

ibireme commented Apr 2, 2016

Fixed.

@ibireme ibireme closed this as completed Apr 15, 2016
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

2 participants