2016-11-30 17 views
0
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'迅速跑环“NSFastEnumerationIterator.Element”(又名“任意”)是无法转换为“的UIView”

我试图取代for subviews : UIView in _buttonsfor subviews : UIView in _buttons as [AnyObject]但不起作用。

我该如何继续?

+0

什么是'buttons'?什么数组? –

+0

请在设置按钮阵列时显示代码 –

+0

是的,_buttons是一个可变数组 – roronoa

回答

0

您需要声明您的收藏像var buttons: [UIView],以确保它仅包含UIView小号

+0

抱歉,但按钮是我的自定义UIButton的类。它是一个UIButton类而不是UIView – roronoa

+0

然后你需要添加'var buttons:[UIButton]' –