我正在开发一个应用程序,其中我希望按行间隔打印值,为此我将NSArray用于多个对象,并将这些对象传递到CGContextShowTextAtPoint()方法中。代码是。
CGContextMoveToPoint(ctx, 30.0, 200.0);
CGContextAddLineToPoint(ctx, 30.0, 440.0);
NSArray *hoursInDays = [[NSArray alloc] initWithObjects:@"0",@"1",@"3",@"4",@"5",@"6",@"7",@"8",@"9",@"10",@"11",@"12", nil];
int intHoursInDays = 0;
for(float y = 400.0; y >= 200.0; y-=18, intHoursInDays++)
{
CGContextSetRGBStrokeColor(ctx, 2.0, 2.0, 2.0, 1.0);
CGContextMoveToPoint(ctx, 28, y);
CGContextAddLineToPoint(ctx, 32, y);
CGContextSelectFont(ctx, "Helvetica", 12.0, kCGEncodingMacRoman);
CGContextSetTextDrawingMode(ctx, kCGTextFill);
CGContextSetRGBFillColor(ctx, 0, 255, 255, 1);
CGAffineTransform xform = CGAffineTransformMake(
1.0, 0.0,
0.0, -1.0,
0.0, 0.0);
CGContextSetTextMatrix(ctx, xform);
NSString *arrayDataForYAxis = [hoursInDays objectAtIndex:intHoursInDays];
CGContextShowTextAtPoint(ctx, 10.0, y+20, [arrayDataForYAxis UTF8String], strlen((char *)arrayDataForYAxis));
CGContextStrokePath(ctx);
}
上面的代码是执行的,但它给我的输出是{oo,1o,2o,…..11},我想要的输出是{0,1,2,3………..11,12}。
上面的代码在一位数后面加了一个字符“o”,我想在CGContextShowTextAtpoint CGContextShowTextAtpoint()方法中第5个参数的参数类型转换附近遇到的问题。如何解决在CGContextShowTextAtpoint()方法中打印NSSArray对象的类型转换问题??????????????