質問編集履歴
1
コードの記載ミスを修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -3,6 +3,10 @@
|
|
3
3
|
実装済みのwebView上でマルチタッチ(4本以上)を検出したいのですが、反応してくれません。
|
4
4
|
|
5
5
|
ごく稀に「touch」の表示がされるのですが、そもそも1本であろうと反応が悪いのはなぜでしょうか?
|
6
|
+
|
7
|
+
|
8
|
+
|
9
|
+
※コードを変更しました
|
6
10
|
|
7
11
|
|
8
12
|
|
@@ -28,9 +32,11 @@
|
|
28
32
|
|
29
33
|
|
30
34
|
|
31
|
-
let
|
35
|
+
let display = self.view.frame.size
|
32
36
|
|
33
|
-
let frame = CGRect(x: 0, y: 0, width:
|
37
|
+
let frame = CGRect(x: 0.0, y: 0.0, width: display.width, height: display.height)
|
38
|
+
|
39
|
+
|
34
40
|
|
35
41
|
webView = UIWebView(frame: frame)
|
36
42
|
|
@@ -38,39 +44,81 @@
|
|
38
44
|
|
39
45
|
webView.isOpaque = false
|
40
46
|
|
41
|
-
webView.backgroundColor = .
|
47
|
+
webView.backgroundColor = UIColor.clear
|
42
48
|
|
43
49
|
webView.scrollView.isScrollEnabled = false
|
44
50
|
|
45
|
-
|
51
|
+
|
46
|
-
|
47
|
-
webView.isUserInteractionEnabled = true
|
48
52
|
|
49
53
|
self.view.addSubview(webView)
|
50
54
|
|
51
55
|
self.view.sendSubview(toBack: webView)
|
52
56
|
|
53
|
-
|
54
|
-
|
55
|
-
let gestureRecognizer = UITapGestureRecognizer(target: self, action: #selector(self.tapGesuture(gestureRecognizer:)))
|
56
|
-
|
57
|
-
gestureRecognizer.delegate = self
|
58
|
-
|
59
|
-
webView.addGestureRecognizer(gestureRecognizer)
|
60
|
-
|
61
57
|
}
|
62
58
|
|
63
59
|
|
64
60
|
|
65
|
-
func t
|
61
|
+
override func touchesEnded(_ touches: Set<UITouch>, with event: UIEvent?) {
|
66
62
|
|
67
|
-
pr
|
63
|
+
super.touchesEnded(touches, with: event)
|
68
64
|
|
69
|
-
|
65
|
+
|
70
66
|
|
71
|
-
|
67
|
+
let touch: UITouch = touches.first! as UITouch
|
72
68
|
|
69
|
+
if touch.view == webView {
|
70
|
+
|
73
|
-
print("
|
71
|
+
print("touch")
|
72
|
+
|
73
|
+
}
|
74
|
+
|
75
|
+
|
76
|
+
|
77
|
+
if (event?.allTouches?.count)! > 4 {
|
78
|
+
|
79
|
+
let size = #imageLiteral(resourceName: "stamp_mark").size
|
80
|
+
|
81
|
+
let window = self.view.frame
|
82
|
+
|
83
|
+
let imageView = UIImageView()
|
84
|
+
|
85
|
+
|
86
|
+
|
87
|
+
imageView.alpha = 0.8
|
88
|
+
|
89
|
+
imageView.image = #imageLiteral(resourceName: "stamp_mark")
|
90
|
+
|
91
|
+
imageView.frame = CGRect(x: (window.width/2 - size.width/2), y: (window.height/2 - size.height/2), width: size.width, height: size.height)
|
92
|
+
|
93
|
+
imageView.transform = CGAffineTransform(scaleX: 3.0, y: 3.0)
|
94
|
+
|
95
|
+
|
96
|
+
|
97
|
+
self.view.addSubview(imageView)
|
98
|
+
|
99
|
+
|
100
|
+
|
101
|
+
UIView.animate(withDuration: 0.3, animations: {
|
102
|
+
|
103
|
+
imageView.transform = CGAffineTransform(scaleX: 1.0, y: 1.0)
|
104
|
+
|
105
|
+
})
|
106
|
+
|
107
|
+
|
108
|
+
|
109
|
+
UIView.animate(withDuration: 8, animations: {
|
110
|
+
|
111
|
+
imageView.transform = CGAffineTransform(rotationAngle: CGFloat(M_PI))
|
112
|
+
|
113
|
+
})
|
114
|
+
|
115
|
+
|
116
|
+
|
117
|
+
DispatchQueue.main.asyncAfter(deadline: .now() + 1.5, execute: {
|
118
|
+
|
119
|
+
imageView.removeFromSuperview()
|
120
|
+
|
121
|
+
})
|
74
122
|
|
75
123
|
}
|
76
124
|
|