所以我有一个图表绘图视图。它位于以模态形式呈现的视图控制器中。问题是 drawInRect 没有被调用。这是为什么?视图在 Interface Builder 中设置,并初始化...
- (void)viewWillAppear:(BOOL)animated
{
minVal = [self.delegate minValue];
maxVal = [self.delegate maxValue];
noSteps = [self.delegate noSteps];
stepVal = [self.delegate stepValue];
data = [self.delegate dataArray];
formulaName = [self.delegate formulaName];
self.titleLabel.text = formulaName;
// draw the chart
self.chartView = [[PSChartIOS alloc] initWithFrame:self.chartView.bounds andChartType:PSChartTypeColumn];
[self.chartView setDataSource:self];
[self.chartView setChartTitle:@""];
[self.chartView setPanOXAxis:YES];
[self.chartView setTitleColor:[UIColor redColor]];
[self.chartView setStartAtTheEnd:NO];
//[chart setAutoresizingMask: UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth];
[self.chartView loadData];
[self.chartView setNeedsDisplay];
// NSLog(@"autoresize mask :%d",self.view.autoresizingMask);
// [self.view addSubview:self.chartView];
// [self.chartView addSubview:chart];
[super viewWillAppear:animated];
}
所有的委托方法都被调用,所以视图有它的数据......它从不绘制......我有一种感觉,问题可能是 self.chartView.bounds .. 但这应该只是返回在 IB 中设置的边界...
发现问题:
NSLog(@"the bounds %@",NSStringFromCGRect( self.chartView.bounds));
返回
the bounds {{0, 0}, {0, 0}}
我以为它会从 IB 那里得到限制 .. 显然不是