質問編集履歴
2
修正依頼対応
title
CHANGED
File without changes
|
body
CHANGED
@@ -20,4 +20,55 @@
|
|
20
20
|
|
21
21
|
どなたかご存知の方がいたら教えていただけると助かります。
|
22
22
|
|
23
|
-
よろしくお願いいたします。
|
23
|
+
よろしくお願いいたします。
|
24
|
+
|
25
|
+
##【追記:ViewController】
|
26
|
+
UITextFieldに関係あるところだけ抜粋します。
|
27
|
+
calc()の部分はコメントアウトしても今回の現象は発生したので関係ないと思います。
|
28
|
+
```ここに言語を入力
|
29
|
+
@IBOutlet weak var money: UITextField!
|
30
|
+
|
31
|
+
// 入力桁数制限処理
|
32
|
+
@IBAction func moneyEdintingChanged(_ sender: UITextField) {
|
33
|
+
guard let strInputMoney = sender.text else { return }
|
34
|
+
sender.text = String(strInputMoney.prefix(maxAmountLength))
|
35
|
+
}
|
36
|
+
|
37
|
+
// フォーカスイン処理
|
38
|
+
@IBAction func moneyEditingDidBegin(_ sender: UITextField) {
|
39
|
+
let strInputMoney :String = sender.text ?? ""
|
40
|
+
sender.text = self.exceptComma(strMoney: strInputMoney)
|
41
|
+
}
|
42
|
+
|
43
|
+
// フォーカスアウト処理
|
44
|
+
@IBAction func moneyEditingDidEnd(_ sender: UITextField) {
|
45
|
+
let intInputMoney: Int = Int(sender.text!) ?? 0
|
46
|
+
guard intInputMoney != 0 else { return }
|
47
|
+
sender.text = self.addComma(intMoney: intInputMoney)
|
48
|
+
// 計算処理
|
49
|
+
self.calc()
|
50
|
+
}
|
51
|
+
|
52
|
+
// 3桁区切りのカンマがあれば除外する
|
53
|
+
func exceptComma(strMoney: String) -> String {
|
54
|
+
return strMoney.replacingOccurrences(of: ",", with: "")
|
55
|
+
}
|
56
|
+
|
57
|
+
// 3桁区切りのカンマを付ける
|
58
|
+
func addComma(intMoney: Int) -> String {
|
59
|
+
let formatter = NumberFormatter()
|
60
|
+
formatter.numberStyle = NumberFormatter.Style.decimal
|
61
|
+
formatter.groupingSeparator = ","
|
62
|
+
formatter.groupingSize = 3
|
63
|
+
return formatter.string(from: NSNumber.init(integerLiteral: intMoney))!
|
64
|
+
}
|
65
|
+
|
66
|
+
func calc() {
|
67
|
+
// 色々計算する
|
68
|
+
}
|
69
|
+
|
70
|
+
// キーボードを非表示にする
|
71
|
+
override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
|
72
|
+
self.view.endEditing(true)
|
73
|
+
}
|
74
|
+
```
|
1
誤字、タグ追加
title
CHANGED
File without changes
|
body
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
##【現象】
|
6
6
|
あるViewの上に別のViewを被せて、ボタンをタップしたら被せたViewの位置をanimateで動かしています。
|
7
7
|
|
8
|
-
しかしなぜか、
|
8
|
+
しかしなぜか、UITextFieldに値を入力すると、被せたViewの移動した位置がリセット(元の位置になる)されてしまいます。
|
9
9
|
|
10
10
|
##調査したこと
|
11
11
|
animateのロジックは以下です。
|
@@ -16,7 +16,7 @@
|
|
16
16
|
```
|
17
17
|
|
18
18
|
他のUIButtonをタップしたり、UISegmentedControlをタップするだけならリセットは発生しません。
|
19
|
-
|
19
|
+
UITextFieldにフォーカスするだけでも起こらないので、UITextFieldに値が入る時に発生すると思うのですが、なぜそうなるのか、それ以上原因の追究ができませんでした。
|
20
20
|
|
21
21
|
どなたかご存知の方がいたら教えていただけると助かります。
|
22
22
|
|