0

iOS 6 では正常に動作するが iOS7 では動作しない機能の下の PDF 生成機能に取り組んでいるので、同じ問題について助けてください。

 (float) drawText:(NSString *)body currentVehical:(NSInteger)currentVehical{

    CGContextRef    currentContext = UIGraphicsGetCurrentContext();

    CGContextSetRGBFillColor(currentContext, 0.0, 0.0, 0.0, 1.0);

    UIFont *font = [UIFont systemFontOfSize:14.0];

    NSLog(@" FRame : \n%f\n%f",(self.pageSize.width - 2*kBorderInset-2*kMarginInset), 

(self.pageSize.height - 2*kBorderInset - 2*kMarginInset));

    CGSize stringSize = [body sizeWithFont:font
                         constrainedToSize:CGSizeMake(self.pageSize.width - 2*kBorderInset-2*kMarginInset, self.pageSize.height - 2*kBorderInset - 2*kMarginInset)
                             lineBreakMode:NSLineBreakByWordWrapping];


    CGRect renderingRect = CGRectMake(120,10+self.yCord, self.pageSize.width - 120,stringSize.height+KExtraSpaces);

    NSLog(@"PDF draw rect: %@",NSStringFromCGRect(renderingRect));

    if (IS_IOS7) {
        NSMutableParagraphStyle *paragraphstyle = [[NSMutableParagraphStyle defaultParagraphStyle] mutableCopy];
        paragraphstyle.lineBreakMode = NSLineBreakByWordWrapping;
        paragraphstyle.alignment = NSTextAlignmentLeft;
        NSDictionary * attributes = @{ NSFontAttributeName:font, NSParagraphStyleAttributeName: paragraphstyle };
            //[body drawInRect:renderingRect withAttributes:attributes];
        NSStringDrawingContext *context = [NSStringDrawingContext new];
        context.minimumScaleFactor = 0.1;
        NSLog(@"body :%@",body);
        [body drawWithRect:renderingRect options:NSStringDrawingUsesLineFragmentOrigin attributes:attributes context:context];
    }else{

    [body drawInRect:renderingRect withFont:font lineBreakMode:NSLineBreakByWordWrapping alignment:NSTextAlignmentLeft];
    }
    return stringSize.height;
}

前もって感謝します。

4

1 に答える 1