2013-04-04 93 views
-1

我加入共享功能,以我的iOS应用(我必须向下支持到iOS 5.0在IOS在IOS5,但崩溃工作6

下面的代码是要在一个标签,它被正常工作在IOS5但崩溃IN IOS 6

CGContextStrokePath(c)中崩溃;

CFIndex lineIndex = 0; 
for (id line in lines) {   
    CGFloat ascent = 0.0f, descent = 0.0f, leading = 0.0f; 
    CGFloat width = CTLineGetTypographicBounds((__bridge CTLineRef)line, &ascent, &descent, &leading) ; 
    CGRect lineBounds = CGRectMake(0.0f, 0.0f, width, ascent + descent + leading) ; 
    lineBounds.origin.x = origins[lineIndex].x; 
    lineBounds.origin.y = origins[lineIndex].y; 

    for (id glyphRun in (__bridge NSArray *)CTLineGetGlyphRuns((__bridge CTLineRef)line)) { 
     NSDictionary *attributes = (__bridge NSDictionary *)CTRunGetAttributes((__bridge CTRunRef) glyphRun); 
     BOOL strikeOut = [[attributes objectForKey:kTTTStrikeOutAttributeName] boolValue]; 
     NSInteger superscriptStyle = [[attributes objectForKey:(id)kCTSuperscriptAttributeName] integerValue]; 

     if (strikeOut) { 
      CGRect runBounds = CGRectZero; 
      CGFloat runAscent = 0.0f; 
      CGFloat runDescent = 0.0f; 

      runBounds.size.width = CTRunGetTypographicBounds((__bridge CTRunRef)glyphRun, CFRangeMake(0, 0), &runAscent, &runDescent, NULL); 
      runBounds.size.height = runAscent + runDescent; 

      CGFloat xOffset = CTLineGetOffsetForStringIndex((__bridge CTLineRef)line, CTRunGetStringRange((__bridge CTRunRef)glyphRun).location, NULL); 
      runBounds.origin.x = origins[lineIndex].x + rect.origin.x + xOffset; 
      runBounds.origin.y = origins[lineIndex].y + rect.origin.y; 
      runBounds.origin.y -= runDescent; 

      // Don't draw strikeout too far to the right 
      if (CGRectGetWidth(runBounds) > CGRectGetWidth(lineBounds)) { 
       runBounds.size.width = CGRectGetWidth(lineBounds); 
      } 

      switch (superscriptStyle) { 
       case 1: 
        runBounds.origin.y -= runAscent * 0.47f; 
        break; 
       case -1: 
        runBounds.origin.y += runAscent * 0.25f; 
        break; 
       default: 
        break; 
      } 

      // Use text color, or default to black 
      id color = [attributes objectForKey:(id)kCTForegroundColorAttributeName]; 

      if (color) { 
       CGContextSetStrokeColorWithColor(c, (__bridge CGColorRef)color); 
      } else { 
       CGContextSetGrayStrokeColor(c, 0.0f, 1.0); 
      } 

      CTFontRef font = CTFontCreateWithName((__bridge CFStringRef)self.font.fontName, self.font.pointSize, NULL); 
      CGContextSetLineWidth(c, CTFontGetUnderlineThickness(font)); 
      CGFloat y = roundf(runBounds.origin.y + runBounds.size.height/2.0f); 
      CGContextMoveToPoint(c, runBounds.origin.x, y); 
      CGContextAddLineToPoint(c, runBounds.origin.x + runBounds.size.width, y); 

      CGContextStrokePath(c); 
     } 
    } 

    lineIndex++; 
} 

}

回答

4

它的一个的错误退房this issue

希望有人可以解决,你会得到解决。 WATCHOUT那里,直到你得到解决。

相关问题