0
我的應用程序中有一些代碼用於格式化用戶在輸入時輸入的值。文本字段使用用戶的本地貨幣符號和小數點類型來格式化輸入。自動文本框格式不適用於iOS 7
問題是,雖然這在iOS 8中適用於很多貨幣(如歐元,美元,英鎊等),但它並未針對iOS 7中的某些貨幣進行適當格式化。我剛更改我的部署目標是從iOS 8到iOS 7,並將其視爲一個問題。
這裏是我的代碼:
func textFieldDidChangeValue(textField: UITextField) {
//Automatic formatting for transaction value text field. Target is added above.
var text = textField.text.stringByReplacingOccurrencesOfString(currencyFormatter.currencySymbol, withString: "").stringByReplacingOccurrencesOfString(currencyFormatter.groupingSeparator, withString: "").stringByReplacingOccurrencesOfString(currencyFormatter.decimalSeparator, withString: "")
textField.text = currencyFormatter.stringFromNumber((text as NSString).doubleValue/100.0)
currencyDouble = (text as NSString).doubleValue/100.0
println(currencyDouble)
valueEnter.alpha = 100
}
當我改變設備的位置,以一個歐洲國家(對歐元),並嘗試輸入值,第一個數字正確輸入,但在那之後我進不了別的也不刪除輸入的值。
關於這個功能與iOS 7到8有什麼不同?我該如何解決它?