0
我有一段應用程序用於將單位從英尺和英寸轉換爲釐米。將UITextField值轉換爲NSString
我接受用戶的腳和英寸通過兩個UITextField輸入工作正常。然後我想對輸入的值進行計算並將結果顯示在下面的標籤中。點擊「轉換」按鈕時,我用於計算的代碼如下所示;
-(IBAction)heighConvertButtonAction:(id)sender {
NSString *feetCM = heightFeetField.text;
NSString *inchesCM = heightInchesField.text;
float fFeet = 30.48 * [feetCM integerValue];
float fInches = 2.54 * [inchesCM integerValue];
float fFeetInches = fFeet + fInches;
fFeetInchesResult = [NSString stringWithFormat:@"%", fFeetInches];
heightCMLabel.text = fFeetInchesResult;
}
它工作在這個意義上,它不產生任何錯誤,但是,當轉換按鈕被觸摸它不會做任何事情。我希望能夠用結果填充'heightCMLabel'標籤。
任何幫助,將不勝感激。
感謝
這是不是在發佈一個錯誤,我只是很愚蠢的!謝謝馬克,那很好。 – 2011-05-30 16:26:29