如果我已經格式化像一個文本框:檢索UITextfField值並將其轉換爲帶有小數的英寸?
//Formats the textfield based on the pickers.
- (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component {
NSString *result = [feetArray objectAtIndex:[feetPicker selectedRowInComponent:0]];
result = [result stringByAppendingFormat:@"%@ft", [feetArray objectAtIndex:[feetPicker selectedRowInComponent:1]]];
result = [result stringByAppendingFormat:@" %@", [inchArray objectAtIndex:[inchesPicker selectedRowInComponent:0]]];
result = [result stringByAppendingFormat:@"%@", [inchArray objectAtIndex:[inchesPicker selectedRowInComponent:1]]];
result = [result stringByAppendingFormat:@" %@in", [fractionArray objectAtIndex:[fractionPicker selectedRowInComponent:0]]];
myTextField.text = result;
}
哪像00ft 00 0/16in
的文本框顯示的我怎樣才能改變,所有與十進制英寸?我需要把英尺乘以12 =變量。然後將其加到英寸,以及將我的分數1/16除以16得到我的小數值,然後將其加到英寸中,顯示爲1234.0625,以便進行計算。有人能幫我完成這件事嗎?先謝謝你!
現在我得到的文本字段的值是這樣的'double a = [[RiseTextField text] doubleValue];'我猜我需要一些如何調用'totalInInchesString'? – Jason 2011-06-14 13:27:33
像這樣:'double a = [totalInInchesString floatValue];'? – Jason 2011-06-14 13:47:10
似乎並沒有將分數分解...... – Jason 2011-06-14 14:02:16