我想在标签中显示 1十进制位置的步进值
我想将double值舍入到1位小数?
这里是我的代码:
- (void)viewDidLoad {
[super viewDidLoad];
[_stepperName addTarget:self action:@selector(stepperMethodName) forControlEvents:UIControlEventValueChanged];
}
-(void)stepperMethodName {
_labelToDisplay.text = [NSString stringWithFormat:@"%f", _stepperName.value];
NSLog(@"%f", _stepperName.value);
}
三江源。
答案 0 :(得分:-1)
- (void)viewDidLoad {
[super viewDidLoad];
[_stepperName addTarget:self action:@selector(stepperMethodName) forControlEvents:UIControlEventValueChanged];
}
-(void)stepperMethodName {
_labelToDisplay.text = [NSString stringWithFormat:@"%.1f", _stepperName.value];
NSLog(@"%.1f", _stepperName.value);
}
//Upto two decimal Places @"%.2f"
//Upto three decimal Places @"%.3f"