应用中点击计算按钮时的代码:
float sqft = ([textfield1.text floatValue]);
float thick= ([textfield2.text floatValue]);
float cos = ([textfield3.text floatValue]);
float eff = ([textfield4.text floatValue]);
float num = ((thick*.5)*sqft)/eff;
float cost = (num*cos);
float costft = (cost/sqft);
label1.text = [NSString stringWithFormat:@"%2.f",num];
label2.text = [NSString stringWithFormat:@"%2.f",cost];
label3.text = [NSString stringWithFormat:@"%2.f",costft];
但是label只返回0?我设置了标签为字符串。但是结果是一样的。