gpt4 book ai didi

objective-c - NSString sizeWithAttributes在iOS 12上崩溃

转载 作者:行者123 更新时间:2023-12-02 07:01:00 24 4
gpt4 key购买 nike

我最近在使用歌词组件时遇到了一个奇怪的崩溃。语言是Objective-C。这场愚蠢的崩溃使我困扰了很多天。

这是代码:

CGFloat charWidth = [character.character sizeWithAttributes:@{NSFontAttributeName:displayFont}].width;

和我的崩溃日志堆栈:
0 CoreText 0x0000000234f09938 __ZNK12TSplicedFont23GetOpticalSizeComponentEd + 148
1 CoreText 0x0000000234e7ffcc __ZL28DerivedOpticalFontDescriptorPK18__CTFontDescriptorPK9TBaseFontd + 120
2 CoreText 0x0000000234e88008 __ZN12TFontCascade26InitCascadeFallbackAtIndexElRj + 252
3 CoreText 0x0000000234e87a70 __ZNK12TFontCascade14CreateFallbackEPK8__CTFontPK10__CFString13CTEmojiPolicy + 728
4 CoreText 0x0000000234e54e40 __ZN13TGlyphEncoder21AppendUnmappedCharRunEjR6TCFRefIP5CTRunEPK8__CTFontR7CFRangeS8_R10TGlyphListI18TDeletedGlyphIndexESD_RK12TFontCascadeNS_15ClusterMatchingEb + 704
5 CoreText 0x0000000234e54900 __ZN13TGlyphEncoder28RunUnicodeEncoderRecursivelyEjO6TCFRefIP5CTRunEPK8__CTFont7CFRangeR10TGlyphListI18TDeletedGlyphIndexESC_PK12TFontCascadeNS_15ClusterMatchingEb + 1900
6 CoreText 0x0000000234e54114 __ZN13TGlyphEncoder17RunUnicodeEncoderEO6TCFRefIP5CTRunEPK8__CTFont7CFRangeR10TGlyphListI18TDeletedGlyphIndexEPK12TFontCascade + 128
7 CoreText 0x0000000234e53c30 __ZN13TGlyphEncoder11EncodeCharsE7CFRangeRK11TAttributesNS_9FallbacksE + 1240
8 CoreText 0x0000000234e6acb0 __ZN21TTypesetterAttrString10InitializeEPK20__CFAttributedString + 304
9 CoreText 0x0000000234e6ab6c __ZN21TTypesetterAttrStringC2EPK20__CFAttributedStringPK14__CFDictionary + 200
10 CoreText 0x0000000234e58070 CTLineCreateWithAttributedString + 60
11 UIFoundation 0x000000023b72be2c -[NSCoreTypesetter _stringDrawingCoreTextEngineWithOriginalString:rect:padding:context:forceClipping:styledTextOptions:attributes:stringDrawingOptions:drawingContext:wantsTextLineFragments:validatedAttributedString:firstNonRenderedCharacterIndex:foundSoftHyphenAtEOL:enginePathUsed:] + 1344
12 UIFoundation 0x000000023b7aae38 ___NSStringDrawingEngine + 3104
13 UIFoundation 0x000000023b72eb04 -[NSString(NSExtendedStringDrawing) boundingRectWithSize:options:attributes:context:] + 160
14 UIFoundation 0x000000023b7307dc -[NSString(NSStringDrawing) sizeWithAttributes:] + 120

最佳答案

我已经解决了这个问题。此方法必须在主线程中调用– JethroYe

关于objective-c - NSString sizeWithAttributes在iOS 12上崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53774590/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com