【发布时间】:2012-05-23 01:16:21
【问题描述】:
所以我的视图中有这个滑块,最大值为 13,最小值为 1。取决于您移动滑块的方式,数字会发生变化,并且可以显示在显示滑块当前数字的标签上.
我希望能够将滑块中的 int 更改为字符串;所以如果滑块的进度是 13,我希望标签读取“A+”,12 带有“A”,11 带有“A-”等等。
因为我有多个滑块而不必制作 13 个“if”语句,有没有办法制作一种方法来检查滑块的进度,然后将数字转换为所需的字母等级?
这是我的其中一个滑块的代码
-(IBAction)sliderChanged:(id)sender{
UISlider *slider = (UISlider *)sender;
int progress = (int)roundf(slider.value);
c1Grade.text = [NSString stringWithFormat:@"%d",progress];
}
// c1Grade is the label next to the slider showing the progress
【问题讨论】:
标签: objective-c ios string int