iphone - 为 UISlider 使用字符串数组

标签 iphone ios cocoa-touch

我想用基于数组的字符串更改 UILabel。这是我目前所拥有的:

- (IBAction) sliderValueChanged:(UISlider *)sender {
   scanLabel.text = [NSString stringWithFormat:@" %.f", [sender value]];
    NSString *wholeText = @"Very Bad";
    self.scanLabel.text = wholeText;

}

我想要不同的值来表示“非常糟糕、糟糕、还好、好、非常好”,而不仅仅是“非常糟糕”。

我在哪里声明 NSMutableArray,我如何用 slider 实现它?

更新:感谢大家的帮助! (我喜欢计算器)

最佳答案

这不是经过编译器检查的……但您可能会有所了解。

NSArray *texts=[NSArray arrayWithObjects:@"very Bad", @"Bad", @"Okay", @"Good", @"Very Good",nil];
NSInteger sliderValue=[sender value]; //make the slider value in given range integer one.
self.scanLabel.text=[texts objectAtIndex:sliderValue];

关于iphone - 为 UISlider 使用字符串数组,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14286206/

相关文章:

iphone - 旋转设备后返回 UITableViewController 时 popViewController 非常慢

iphone - 在 XCode 中每个目标有多个实现是否可以?

ios - 连续使用三个 NSURLConnections 会导致第三次调用挂起

iphone - iOS 开发 : Why doesn't the Phone Keyboard display when I specify UIKeyboardTypePhonePad?

iphone - 如何取消performSelectorOnMainThread?

objective-c - 按 UIButton 导致无法识别的选择器错误

ios - 如何以编程方式检查 iPhone 是否从 sleep 状态变为事件状态?

iphone - 如何在 iPhone 不自动旋转的情况下检测旋转?

ios - EXC_BAD_ACCESS(代码=EXC_I386_GPFLT)当deleteRows(在: [IndexPath])

ios - 带有按钮或图像的警报 Controller