gpt4 book ai didi

arrays - 是否可以在 Swift 中将子类型的元组添加到类型的元组数组中?

转载 作者:行者123 更新时间:2023-11-28 14:06:51 24 4
gpt4 key购买 nike

我想声明这个常量:

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)'

我怎样才能做到这一点?

最佳答案

你必须写

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)
]

关于arrays - 是否可以在 Swift 中将子类型的元组添加到类型的元组数组中?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52909057/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com