为什么UITapGestureRecognizer会向选择器的函数参数本身发送?

时间:2017-10-11 10:33:11

标签: ios swift uigesturerecognizer

为什么UITapGestureRecognizer会在函数调用中粘贴参数时发送到选择器的函数参数?

 blackView.addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(handleDismiss)))


  func handleDismiss(setting: Setting){
    UIView.animate(withDuration: 0.5, delay: 0, usingSpringWithDamping: 1, initialSpringVelocity: 1, options: .curveEaseOut, animations: {
        self.blackView.alpha = 0
        if let window = UIApplication.shared.keyWindow {
            self.collectionView.frame = CGRect(x:0,y: window.frame.height, width: self.collectionView.frame.width, height: self.collectionView.frame.height)

        }

    }, completion: {
        (completed: Bool) in



        if setting.name != "" && setting.name != "Cancel"  {
            self.homeController?.showControllerForSetting(setting: setting)
        }
    })

}

所以当我点击视图时它会调用这个函数,但是函数调用中没有粘贴实际参数,所以gesturerecognizer发送到参数intself https://drive.google.com/open?id=0Bz964D-WrU9KT1RDenFGbktLVEE这里是调试图片。

0 个答案:

没有答案