这可能应该是一个快照,但我被卡住了。当我在任一文本字段中输入小数时,标签中的总数会向上取整。我希望标签将总数显示到两个地方。这是我到目前为止所拥有的:
#import <UIKit/UIKit.h>
@interface ViewController : UIViewController {
IBOutlet UITextField *value1;
IBOutlet UITextField *value2;
IBOutlet UILabel *label;
}
-(IBAction)calculate:(id)sender;
@end
@implementation ViewController
-(IBAction)calculate:(id)sender {
float x = ([value1.text floatValue]);
float y = x*([value2.text floatValue]);
label.text = [[NSString alloc] initWithFormat:@"%2.f", y];
}