在写这篇文章之前,xxx已经写过了几篇关于改对象调用主题的文章,想要了解的朋友可以去翻一下之前的文章
graph.plotAreaFrame.paddingLeft +=5;
graph.plotAreaFrame.paddingTop +=5;
graph.plotAreaFrame.paddingRight +=5;
graph.plotAreaFrame.paddingBottom +=17.5;
[selfsetAllowPinchScaling:NO];//制止缩放
plotSpace.yRange = [CPTPlotRangeplotRangeWithLocation:CPTDecimalFromInt(0)length:CPTDecimalFromFloat(1)];
plotSpace.globalYRange = [CPTPlotRangeplotRangeWithLocation:CPTDecimalFromInt(0)length:CPTDecimalFromFloat(1)];
plotSpace.xRange = [CPTPlotRangeplotRangeWithLocation:CPTDecimalFromInt(1)length:CPTDecimalFromFloat(1)];
plotSpace.globalXRange = [CPTPlotRangeplotRangeWithLocation:CPTDecimalFromInt(0)length:CPTDecimalFromFloat(2)];
x.axisLabels = [self buildLabelTitle];
x.labelingPolicy = CPTAxisLabelingPolicyNone;//当设置这个Policy以后,坐标轴label及背景线tick都须要自己绘制,否则表现为空,请不要适度惊慌
x.minorTickLocations = [NSSetsetWithArray:locationLabels];
- (NSMutableSet*)buildLabelTitle
{
NSMutableSet *newAxisLabels = [NSMutableSetset];
CPTMutableTextStyle *textStyleB = [CPTMutableTextStyletextStyle];
textStyleB.color = [CPTColorcolorWithComponentRed:CPTFloat((float)0x09/0xFF)green:CPTFloat((float)0x31/0xFF)blue:CPTFloat((float)0x4A/0xFF)alpha:CPTFloat(1.0)];
int n = 1;
for ( NSUInteger i =30; i > 0; i--)
{
CPTAxisLabel *newLabel = [[CPTAxisLabelalloc] initWithText:@“这里是内容”
textStyle:textStyleB];
newLabel.tickLocation =CPTDecimalFromUnsignedInteger(n++);
newLabel.offset = 5;
[locationLabels addObject:[NSNumber numberWithFloat:(n-1) -0.25]];
[locationLabels addObject:[NSNumber numberWithFloat:(n-1) +0.25]];
[newAxisLabels addObject:newLabel];
[newLabel release];
}
return newAxisLabels;
}
[[bar1graph] reloadData];
[m_SO2OnlineCaddObject:[NSMutableDictionarydictionaryWithObjectsAndKeys:x, @"x", y,@"y", nil]];
if (tmpY> MAX_data)
{
MAX_data = tmpY;
}
if ([(NSString*)plot.identifierisEqualToString:kBar1])
{
switch (fieldEnum)
{
caseCPTBarPlotFieldBarLocation:
number = [[[m_SO2OnlineCobjectAtIndex:index] valueForKey:@"x"]doubleValue];
break;
caseCPTBarPlotFieldBarTip:
number = [[[m_SO2OnlineCobjectAtIndex:index] valueForKey:@"y"]doubleValue]/ MAX_data;
break;
default:
break;
}
}
这里要记载MAX_data的原因是这里最好应用真实数据的绝对数据,否则当数据值很大的时候会消费corePlot的性能导致图形加载很慢。
[selfperformSelector:@selector(initPlotData)withObject:nilafterDelay:0.2];
NSDateComponents* comps = [[NSDateComponentsalloc]init];
[comps setDay:-i];
NSDate *newDate = [[NSCalendarcurrentCalendar] dateByAddingComponents:compstoDate:[NSDate date]options:0];
--------------------------------------------------------
for (UIView* sbViewin scrvBg.subviews)
{
[sbView removeFromSuperview];
}
这里还有个获得subView的小技巧:
[subView setTag:300];
subView = [self.viewviewWithTag:300]
我这里能给出的教训就是,alloc的对象应该立即release。如果该对象不能立即release,必须保障alloc和release必须配对调用,特别要留意那些可以多次调用且包括alloc却未被实时release的函数。四个字归纳综合“非常危险”!
self.my_arr =[[NSArray alloc]init]; ---------- 错误!
NSArray *tmpArr = [[NSArray alloc]init];
self.my = tmpArr;
[tmpArr release]; ---------- 正确
文章结束给大家分享下程序员的一些笑话语录: 一个合格的程序员是不会写出 诸如 “摧毁地球” 这样的程序的,他们会写一个函数叫 “摧毁行星”而把地球当一个参数传进去。
--------------------------------- 原创文章 By
对象和调用
---------------------------------