質問編集履歴
3
修正依頼
test
CHANGED
File without changes
|
test
CHANGED
@@ -33,3 +33,173 @@
|
|
33
33
|
追記:navigation bar 分の高さを計算に入れてなかったのですがそれが要因になり得ますか?
|
34
34
|
|
35
35
|
試してみたのですが解決できませんでした
|
36
|
+
|
37
|
+
|
38
|
+
|
39
|
+
>newmt様への修正依頼
|
40
|
+
|
41
|
+
```swift
|
42
|
+
|
43
|
+
import UIKit
|
44
|
+
|
45
|
+
|
46
|
+
|
47
|
+
class ViewController: UIViewController, UITextFieldDelegate,UITableViewDelegate,UITableViewDataSource,UIScrollViewDelegate{
|
48
|
+
|
49
|
+
|
50
|
+
|
51
|
+
let userDefaults = UserDefaults.standard
|
52
|
+
|
53
|
+
|
54
|
+
|
55
|
+
@IBOutlet weak var movingBox: UIView!
|
56
|
+
|
57
|
+
@IBOutlet weak var scvBackGround: UIScrollView!
|
58
|
+
|
59
|
+
|
60
|
+
|
61
|
+
|
62
|
+
|
63
|
+
@IBOutlet weak var memoText: UITextField!
|
64
|
+
|
65
|
+
|
66
|
+
|
67
|
+
override func viewWillAppear(_ animated: Bool) {
|
68
|
+
|
69
|
+
super.viewWillAppear(animated)
|
70
|
+
|
71
|
+
|
72
|
+
|
73
|
+
memoText.delegate = self
|
74
|
+
|
75
|
+
|
76
|
+
|
77
|
+
let notificationCenter = NotificationCenter.default
|
78
|
+
|
79
|
+
notificationCenter.addObserver(self, selector: Selector(("handleKeyboardWillShowNotification:")), name: NSNotification.Name.UIKeyboardWillShow, object: nil)
|
80
|
+
|
81
|
+
notificationCenter.addObserver(self, selector: Selector(("handleKeyboardWillHideNotification:")), name: NSNotification.Name.UIKeyboardWillHide, object: nil)
|
82
|
+
|
83
|
+
}
|
84
|
+
|
85
|
+
override func viewWillDisappear(_ animated: Bool) {
|
86
|
+
|
87
|
+
let notificationCenter = NotificationCenter.default
|
88
|
+
|
89
|
+
notificationCenter.removeObserver(self, name: NSNotification.Name.UIKeyboardWillShow, object: nil)
|
90
|
+
|
91
|
+
notificationCenter.removeObserver(self, name: NSNotification.Name.UIKeyboardWillHide, object: nil)
|
92
|
+
|
93
|
+
}
|
94
|
+
|
95
|
+
|
96
|
+
|
97
|
+
override func viewDidLoad() {
|
98
|
+
|
99
|
+
super.viewDidLoad()
|
100
|
+
|
101
|
+
|
102
|
+
|
103
|
+
memoText.returnKeyType = .done
|
104
|
+
|
105
|
+
|
106
|
+
|
107
|
+
}
|
108
|
+
|
109
|
+
|
110
|
+
|
111
|
+
override func didReceiveMemoryWarning() {
|
112
|
+
|
113
|
+
super.didReceiveMemoryWarning()
|
114
|
+
|
115
|
+
// Dispose of any resources that can be recreated.
|
116
|
+
|
117
|
+
}
|
118
|
+
|
119
|
+
|
120
|
+
|
121
|
+
func textFieldShouldReturn(_ textField: UITextField) -> Bool {
|
122
|
+
|
123
|
+
memoText.resignFirstResponder()
|
124
|
+
|
125
|
+
return true
|
126
|
+
|
127
|
+
}
|
128
|
+
|
129
|
+
|
130
|
+
|
131
|
+
override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
|
132
|
+
|
133
|
+
selectArray.removeAll()
|
134
|
+
|
135
|
+
for _ in memoArray {
|
136
|
+
|
137
|
+
selectArray.append(false)
|
138
|
+
|
139
|
+
}
|
140
|
+
|
141
|
+
self.view.endEditing(true)
|
142
|
+
|
143
|
+
}
|
144
|
+
|
145
|
+
|
146
|
+
|
147
|
+
func textFieldShouldBeginEditing(_ textField: UITextField) -> Bool {
|
148
|
+
|
149
|
+
|
150
|
+
|
151
|
+
return true
|
152
|
+
|
153
|
+
}
|
154
|
+
|
155
|
+
func handleKeyboardWillShowNotification(notification: NSNotification){
|
156
|
+
|
157
|
+
let userInfo = notification.userInfo!
|
158
|
+
|
159
|
+
let keyboardScreenEndFrame = (userInfo[UIKeyboardFrameEndUserInfoKey] as! NSValue).cgRectValue
|
160
|
+
|
161
|
+
let myBoundSize: CGSize = UIScreen.main.bounds.size
|
162
|
+
|
163
|
+
let navBarHeight:CGFloat = self.navigationController!.navigationBar.bounds.size.height
|
164
|
+
|
165
|
+
|
166
|
+
|
167
|
+
|
168
|
+
|
169
|
+
let movingBottom = movingBox.frame.origin.y + movingBox.frame.height + navBarHeight
|
170
|
+
|
171
|
+
let keyboardTop = myBoundSize.height - navBarHeight - keyboardScreenEndFrame.size.height
|
172
|
+
|
173
|
+
|
174
|
+
|
175
|
+
if movingBottom >= keyboardTop {
|
176
|
+
|
177
|
+
scvBackGround.contentOffset.y = movingBottom - keyboardTop
|
178
|
+
|
179
|
+
}
|
180
|
+
|
181
|
+
}
|
182
|
+
|
183
|
+
func handleKeyboardWillHideNotification(notification: NSNotification) {
|
184
|
+
|
185
|
+
scvBackGround.contentOffset.y = 0
|
186
|
+
|
187
|
+
}
|
188
|
+
|
189
|
+
|
190
|
+
|
191
|
+
}
|
192
|
+
|
193
|
+
```
|
194
|
+
|
195
|
+
階層構造
|
196
|
+
|
197
|
+
![イメージ説明](f019033bfd7e5447404179dce09800f9.png)
|
198
|
+
|
199
|
+
movingBox
|
200
|
+
|
201
|
+
![イメージ説明](4407dabc262d13b5a197a4cb8ad48f6b.png)
|
202
|
+
|
203
|
+
movingBoxとその上の2つの部品のconstrain
|
204
|
+
|
205
|
+
![イメージ説明](0d31b5821f63d953289b8ce28014e873.png)
|
2
追記
test
CHANGED
File without changes
|
test
CHANGED
@@ -27,3 +27,9 @@
|
|
27
27
|
|
28
28
|
|
29
29
|
回答お待ちしております。
|
30
|
+
|
31
|
+
|
32
|
+
|
33
|
+
追記:navigation bar 分の高さを計算に入れてなかったのですがそれが要因になり得ますか?
|
34
|
+
|
35
|
+
試してみたのですが解決できませんでした
|
1
追記:navigation bar 分の高さを計算に入れてなかったのですがそれが要因になり得ますか? 試してみたのですが解決できませんでした
test
CHANGED
File without changes
|
test
CHANGED
File without changes
|