2012-05-26 68 views
0

我無法在我的警報視圖中顯示一個雙精度值。該字符串在AlertView中始終顯示爲0。提前致謝!將文本框加倍然後顯示爲字符串AlertView

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]; 

回答

1

%d(和%i)爲整數(小數)的格式說明。對於浮點數,你應該使用%f

+0

謝謝,這解決了這個問題。 – brmcdani44

相關問題