YYText icon indicating copy to clipboard operation
YYText copied to clipboard

YYLabel在特殊字符串下会崩溃

Open irobbin1024 opened this issue 9 years ago • 3 comments

问题:YYLabel在特殊字符串下会崩溃 导致崩溃的文本:ޙޓゝ₯ 测试机型:iPhone 6 plus 10.3.2 Xcode版本:8.3.3 YYText版本:1.0.7,1.0.5 测试代码:新建一个工程,使用cocoapods集成最新的YYText(1.0.7)

    YYLabel *label = [YYLabel new];
    label.textColor = [UIColor blackColor];
    label.text = @"ޙޓゝ₯";
    [self.view addSubview:label];
    [label sizeToFit];
    
    label.center = CGPointMake(self.view.frame.size.width * 0.5, self.view.frame.size.height * 0.5);

崩溃原因:_displayAsync 函数中UIGraphicsBeginImageContextWithOptions(size, opaque, scale);中的size过大,为YYTextContainerMaxSize定义的0x100000,导致内存分配益处,被iOS系统杀死。Xcode报错信息为:Message from debugger: Terminated due to memory issue。

irobbin1024 avatar Jul 25 '17 07:07 irobbin1024

6s plus也会崩溃

irobbin1024 avatar Jul 31 '17 02:07 irobbin1024

这里是因为没有设置rtl语言NSParagraphStyleAttributeName,设置成NSTextAlignmentLeft后就正常了,但是还是不知道具体什么原因导致foom

MHJcoder avatar Jan 27 '21 02:01 MHJcoder

这里是因为没有设置rtl语言NSParagraphStyleAttributeName,设置成NSTextAlignmentLeft后就正常了,但是还是不知道具体什么原因导致foom

NSMutableAttributedString * attributing =[[NSMutableAttributedString alloc] initWithString:@"𝐊𝐇 ⁵ ¹ ¹ F²"]; nameString.yy_color = [UIColor whiteColor];// nameString.yy_font = [UIFont systemFontOfSize:15]; nameString.yy_alignment = NSTextAlignmentCenter; 有可能崩溃在nameString.yy_color = [UIColor whiteColor]这里,按照你说的,需要先设置 nameString.yy_alignment = NSTextAlignmentCenter;吗?

samllOranges avatar Nov 24 '23 02:11 samllOranges