var _buttons : NSMutableArray = []
override func gestureRecognizerShouldBegin(_ gestureRecognizer: UIGestureRecognizer) -> Bool {
let location : CGPoint = gestureRecognizer.location(in: self)
for subviews : UIView in _buttons {
if subviews.frame.contains(location) {
return false
}
}
return true
}
我这样做但是它出现了错误'NSFastEnumerationIterator.Element' (aka 'Any') is not convertible to 'UIView'
我尝试将for subviews : UIView in _buttons
替换为for subviews : UIView in _buttons as [AnyObject]
,但它不起作用。
我该怎么办?
答案 0 :(得分:0)
您需要将自己的收藏集声明为var buttons: [UIView]
,以确保其仅包含UIView
s