【发布时间】:2012-11-20 05:10:08
【问题描述】:
我在 iOS 中的条形图应用程序出现问题。我使用DSBarChart 和滑块控件创建了一个条形图。我希望图表在更改滑块时动态更改。我怎么做?这是我到目前为止所做的示例代码。
- (void)sliderValueDidChange:(UISlider *)sender {
if((int)slider.value % 10 == 0) {
positionLabel.text = [NSString stringWithFormat:@"%d",(int)slider.value];
myValue = (int)slider.value;
}
NSDictionary *dict =[NSDictionary dictionaryWithObjectsAndKeys:
[NSNumber numberWithInt:10], @"0",
[NSNumber numberWithInt:20], @"1",
[NSNumber numberWithInt:15], @"2",
[NSNumber numberWithInt:25], @"3",
[NSNumber numberWithInt:30], @"4",
[NSNumber numberWithInt:20], @"5",
[NSNumber numberWithInt:15], @"6",
nil];
DSBarChart *chrt = [[DSBarChart alloc] initWithFrame:ChartView.bounds
color:[UIColor greenColor]
andDictionary:dict];
chrt.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
chrt.bounds = ChartView.bounds;
[ChartView addSubview:chrt];
}
【问题讨论】:
-
我不知道你犯了什么错误,你应该让我们知道是什么问题。
-
嗨,我创建了 DSBarChart。你到底想在这里做什么?您是否尝试让多个滑块映射到图表?我不清楚你的问题。如果您可以更清楚地编辑/评论,我会帮助您。
-
嗨,DhilipSiva 先生,我想创建带有滑块控件的条形图。当我的滑块改变或移动时,我的条形图值也会改变,我的图表也会改变。不知道怎么办?
标签: ios slider uislider bar-chart