我想声明这个常量:
let simultaneousGestures: [(UIGestureRecognizer.Type, UIGestureRecognizer.Type)] =
[(UIPanGestureRecognizer, UIPinchGestureRecognizer),
(UIPanGestureRecognizer, UIRotationGestureRecognizer),
(UIPinchGestureRecognizer, UIRotationGestureRecognizer),
(UIPinchGestureRecognizer, UIPanGestureRecognizer),
(UIRotationGestureRecognizer, UIPanGestureRecognizer),
(UIRotationGestureRecognizer, UIPinchGestureRecognizer)
]
但是我得到这个错误:
Cannot convert value of type '(UIPanGestureRecognizer, UIPinchGestureRecognizer).Type' to expected element type '(UIGestureRecognizer.Type, UIGestureRecognizer.Type)'
我该如何实现?
答案 0 :(得分:1)
你必须写
let simultaneousGestures: [(UIGestureRecognizer.Type, UIGestureRecognizer.Type)] =
[(UIPanGestureRecognizer.self, UIPinchGestureRecognizer.self),
(UIPanGestureRecognizer.self, UIRotationGestureRecognizer.self),
(UIPinchGestureRecognizer.self, UIRotationGestureRecognizer.self),
(UIPinchGestureRecognizer.self, UIPanGestureRecognizer.self),
(UIRotationGestureRecognizer.self, UIPanGestureRecognizer.self),
(UIRotationGestureRecognizer.self, UIPinchGestureRecognizer.self)
]