一种由于“ setNeedsLayout”方法引起的“ EXC_BAD_ACCESS”崩溃

问题描述

EXC_BAD_ACCESS方法引起的几次setNeedsLayout崩溃。它们几乎具有相同的崩溃堆栈,如下所示:

已崩溃:com.apple.main-thread
EXC_BAD_ACCESS KERN_INVALID_ADDRESS 0x0000000000000000
CoreText TBMPDataCache::GetDataForCharacter(unsigned int) const + 64
CoreText TBMPDataCache::GetDataForCharacter(unsigned int) const + 28
CoreText TUnicodeEncoder::Encode(__CTFont const*,TCharStreamIterator&,CFRange,unsigned short*,CGSize*,unsigned int*,double*,bool) + 616
CoreText TGlyphEncoder::RunUnicodeEncoderRecursively(unsigned int,TCFRef<CTRun*>&&,__CTFont const*,TInlineVector<long,30ul>&,TFontCascade const*,TGlyphEncoder::ClusterMatching,bool) + 364
CoreText TGlyphEncoder::AppendUnmappedCharRun(unsigned int,TCFRef<CTRun*>&,CFRange&,TFontCascade const&,bool) + 1640
CoreText TGlyphEncoder::RunUnicodeEncoderRecursively(unsigned int,bool) + 1224
CoreText TGlyphEncoder::RunUnicodeEncoder(TCFRef<CTRun*>&&,TFontCascade const*) + 160
CoreText TGlyphEncoder::EncodeChars(CFRange,TAttributes const&,TGlyphEncoder::Fallbacks) + 1024
CoreText TTypesetterattrString::Initialize(__CFAttributedString const*) + 372
CoreText TTypesetterattrString::TTypesetterattrString(__CFAttributedString const*,__CFDictionary const*) + 164
CoreText CTLineCreateWithAttributedString + 136
UIFoundation -[NscoreTypesetter _stringDrawingcoreTextEngineWithOriginalString:rect:padding:graphicsContext:forceClipping:attributes:stringDrawingOptions:drawingContext:wantsTextLineFragments:validatedAttributedString:firstNonRenderedCharacterIndex:foundSoftHyphenAtEOL:enginePathUsed:] + 1280
UIFoundation __NsstringDrawingEngine + 5020
UIFoundation -[Nsstring(NSExtendedStringDrawing) boundingRectWithSize:options:attributes:context:] + 160
UIKitCore -[UILabel _textRectForBounds:limitedToNumberOfLines:includingShadow:] + 2128
UIKitCore -[UILabel _intrinsicSizeWithinSize:] + 504
UIKitCore -[UIView(Geometry) sizetoFit] + 140
MDProject -[MyCollectionViewCell layoutSubviews] + 3509224

layoutSubviews方法,如下所示:

- (void)layoutSubviews
{
    [super layoutSubviews];
    
    self.imageView.left = 15;
    self.imageView.centerY = self.centerY;
    
    [self.titleLabel sizetoFit];
    self.titleLabel.left = self.imageView.right + 12;
    self.titleLabel.top = self.imageView.top + 5;
    
    [self.subTitleLabel sizetoFit];
    self.subTitleLabel.left = self.imageView.right + 12;
    self.subTitleLabel.top = self.titleLabel.bottom + 5;
    
    self.bottomSpaceLineView.width = self.width - 15;
    self.bottomSpaceLineView.top = self.height - 1;
    self.bottomSpaceLineView.left = 15;
}

具体原因是什么?非常感谢。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)