2016-07-13 41 views
1

我試圖添加一個UIGestureRecognizer來隱藏HUD,當用戶觸摸它時。這是我的代碼:如何使用UIGestureRecognizer隱藏PKHUD?

let gesture = UITapGestureRecognizer(target: self, action: #selector(someAction(_:))) 
PKHUD.sharedHUD.contentView.userInteractionEnabled = true 
PKHUD.sharedHUD.contentView.addGestureRecognizer(gesture) 

// ... 

func someAction(sender:UITapGestureRecognizer){ 
    // do task 
} 

但是,觸摸HUD時從不會調用someAction。任何想法如何隱藏PKHUD?我知道,有一個HUD.hide()方法,但我希望用戶決定視圖何時應該消失。

回答

0

嘗試使用:

PKHUD.sharedHUD.dimsBackground: Bool 
+0

這並不提供答案的問題。一旦你有足夠的[聲譽](https://stackoverflow.com/help/whats-reputation),你將可以[對任何帖子發表評論](https://stackoverflow.com/help/privileges/comment);相反,[提供不需要提問者澄清的答案](https://meta.stackexchange.com/questions/214173/why-do-i-need-50-reputation-to-comment-what-c​​an- I-DO-代替)。 - [來自評論](/ review/low-quality-posts/17813631) – manish