2012-06-16 4 views
0

나는 다음과 같은 스택 추적을 가지고 탈주 이유 coretext 알아낼 수 없습니다디버깅 핵심 텍스트는 충돌

enter image description here

-(CGSize)sizeConstrainedToSize:(CGSize)maxSize fitRange:(NSRange*)fitRange { 
    CTFramesetterRef framesetter = CTFramesetterCreateWithAttributedString 
               ((CFAttributedStringRef)self); 
    CFRange fitCFRange = CFRangeMake(0,0); 
    CGSize sz = CTFramesetterSuggestFrameSizeWithConstraints 
         (framesetter,CFRangeMake(0,0),NULL,maxSize,&fitCFRange); 
    if (framesetter) CFRelease(framesetter); 
    if (fitRange) *fitRange = NSMakeRange(fitCFRange.location, fitCFRange.length); 
    // take 1pt of margin for security 
    return CGSizeMake(floorf(sz.width+1) , floorf(sz.height+1)); 
} 
+0

이중 포인터가 눈에 띄었습니까? '* fitRange' – CodaFi

+0

괜찮은 것 같아요. 어떤 경우에는 작동하지만 모든 경우에는 그렇지 않습니다. – xonegirlz

+0

로그에 블록이 너무 많이 덮여있는 것처럼 보입니다 ... GCD를 사용합니까? – CodaFi

답변

0

kCTFontAttributeName의 값이 CTFontRef하지해야합니다 UIFont 포인터. 아마 이런 식으로, 거기에 UIFontCTFontRef에 변환 공용 기능이 없기 때문에 당신은 CTFontCreateWithName를 사용하여 작성해야합니다 : 당신이 CTFramesetterCreateWithAttributedString를 호출에서 충돌을 받고처럼 스택 추적을 바탕으로

UIFont *uiFont = ...; 
CTFontRef ctFont = CTFontCreateWithName((__bridge CFStringRef)uiFont.fontName, uiFont.pointSize, NULL);