質問編集履歴
1
途中までは自己解決したので修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -4,16 +4,50 @@
|
|
4
4
|
|
5
5
|
|
6
6
|
|
7
|
-
今のコードでは
|
7
|
+
今のコードでは1度textViewがタッチされると以降textFieldでもviewがスクロールしてしまします。
|
8
|
-
|
9
|
-
|
8
|
+
|
10
|
-
|
11
|
-
|
9
|
+
原因は
|
12
|
-
|
13
|
-
|
14
10
|
|
15
11
|
```swift
|
16
12
|
|
13
|
+
func isTouch(touches: Set<UITouch>, view:UIView) -> Bool{
|
14
|
+
|
15
|
+
for touch: AnyObject in touches {
|
16
|
+
|
17
|
+
let t: UITouch = touch as! UITouch
|
18
|
+
|
19
|
+
if t.view?.tag == view.tag {
|
20
|
+
|
21
|
+
return true
|
22
|
+
|
23
|
+
} else {
|
24
|
+
|
25
|
+
return false
|
26
|
+
|
27
|
+
}
|
28
|
+
|
29
|
+
}
|
30
|
+
|
31
|
+
return false
|
32
|
+
|
33
|
+
}
|
34
|
+
|
35
|
+
```
|
36
|
+
|
37
|
+
|
38
|
+
|
39
|
+
ここででviewがスクロールする処理が1度解除されると以降textFieldにも適用されてしまうと考えていますが対処の仕方が分からない状態です
|
40
|
+
|
41
|
+
|
42
|
+
|
43
|
+
|
44
|
+
|
45
|
+
|
46
|
+
|
47
|
+
|
48
|
+
|
49
|
+
```swift
|
50
|
+
|
17
51
|
import UIKit
|
18
52
|
|
19
53
|
|
@@ -38,6 +72,10 @@
|
|
38
72
|
|
39
73
|
textField.delegate = self
|
40
74
|
|
75
|
+
textView.tag = 123
|
76
|
+
|
77
|
+
|
78
|
+
|
41
79
|
}
|
42
80
|
|
43
81
|
|
@@ -130,14 +168,56 @@
|
|
130
168
|
|
131
169
|
}
|
132
170
|
|
171
|
+
|
172
|
+
|
173
|
+
|
174
|
+
|
175
|
+
|
176
|
+
|
177
|
+
|
178
|
+
|
133
|
-
|
179
|
+
override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
|
134
|
-
|
135
|
-
|
136
|
-
|
180
|
+
|
137
|
-
fu
|
181
|
+
if isTouch(touches: touches, view: textView) {
|
138
|
-
|
182
|
+
|
139
|
-
self.configureObserver()
|
183
|
+
self.configureObserver()
|
140
|
-
|
184
|
+
|
185
|
+
|
186
|
+
|
187
|
+
|
188
|
+
|
141
|
-
}
|
189
|
+
}
|
190
|
+
|
191
|
+
}
|
192
|
+
|
193
|
+
|
194
|
+
|
195
|
+
func isTouch(touches: Set<UITouch>, view:UIView) -> Bool{
|
196
|
+
|
197
|
+
for touch: AnyObject in touches {
|
198
|
+
|
199
|
+
let t: UITouch = touch as! UITouch
|
200
|
+
|
201
|
+
if t.view?.tag == view.tag {
|
202
|
+
|
203
|
+
return true
|
204
|
+
|
205
|
+
} else {
|
206
|
+
|
207
|
+
return false
|
208
|
+
|
209
|
+
}
|
210
|
+
|
211
|
+
}
|
212
|
+
|
213
|
+
return false
|
214
|
+
|
215
|
+
}
|
216
|
+
|
217
|
+
|
218
|
+
|
219
|
+
|
220
|
+
|
221
|
+
|
142
222
|
|
143
223
|
```
|