Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/116.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone ECGraph的动态值_Iphone_Ios_Graph_Nsarray_Drawrect - Fatal编程技术网

Iphone ECGraph的动态值

Iphone ECGraph的动态值,iphone,ios,graph,nsarray,drawrect,Iphone,Ios,Graph,Nsarray,Drawrect,在我的应用程序中使用时,我需要在drawRect方法中动态添加myTopNameStr,该方法在DisplayView.m中定义(继承自UIView),它来自ECGraphViewController.m中的NSArray - (void)drawRect:(CGRect)rect { NSLog(@"==========%@",topPlace); // Drawing code CGContextRef _context = UIGraphicsGetCurrentContext(); E

在我的应用程序中使用时,我需要在
drawRect
方法中动态添加
myTopNameStr
,该方法在
DisplayView.m
中定义(继承自
UIView
),它来自
ECGraphViewController.m
中的
NSArray

 - (void)drawRect:(CGRect)rect {
NSLog(@"==========%@",topPlace);
// Drawing code
CGContextRef _context = UIGraphicsGetCurrentContext();
ECGraph *graph = [[ECGraph alloc] initWithFrame:CGRectMake(0,0, 320, 480)
                                    withContext:_context isPortrait:YES];
ECGraphItem *item1 = [[ECGraphItem alloc] init];
item1.isPercentage = YES;
item1.yValue = 71;
item1.width = 55;
item1.myTopNameStr = [topPlace objectAtIndex:0];
 // item1.name = @"item1";

ECGraphItem *item2 = [[ECGraphItem alloc] init];
item2.isPercentage = YES;
item2.yValue = 61;
item2.width = 55;
 // item2.myTopNameStr =[_topNameAry objectAtIndex:1];
//item2.name = @"item2";

ECGraphItem *item3 = [[ECGraphItem alloc] init];
item3.isPercentage = NO;
item3.yValue = 51;
item3.width = 55;
 // item3.myTopNameStr =[_topNameAry objectAtIndex:2];
 // item3.name = @"item3";


NSArray *items = [[NSArray alloc] initWithObjects:item1,item2,item3,nil];
 // [graph setXaxisTitle:@"name"];
 // [graph setYaxisTitle:@"Percentage"];
 // [graph setGraphicTitle:@"Top Chat.Points"];
[graph setDelegate:self];
[graph setBackgroundColor:[UIColor whiteColor]];
[graph drawHistogramWithItems:items lineWidth:0 color:[UIColor clearColor]];

}

我还研究了如何将ecgraph集成到iOS应用程序中,以及如何在应用程序的特定区域显示该图形。。对于您的问题,您可以先将数据设置到某个中心位置(如AppDelegate或某些共享实例类),然后在drawRect方法中访问它