0

我无法让双重显示在我的警报视图中。该字符串在 AlertView 中一直显示为 0。提前致谢!

    double binRadius = [txtRadiusInches.text doubleValue] / 12 + [txtRadiusFeet.text doubleValue];
NSString *myString = [NSString stringWithFormat:@"%d", binRadius];

UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Estimatated Amount"
                                                message:myString
                                               delegate:self
                                      cancelButtonTitle:@"Continue"
                                      otherButtonTitles:@"Clear All", nil];

[alert show];
4

1 回答 1

1

%d(and %i) 是整数(小数)的格式说明符。对于浮点数,您应该使用%f.

于 2012-05-26T17:28:10.223 回答