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()方法,但我希望用戶決定視圖何時應該消失。
這並不提供答案的問題。一旦你有足夠的[聲譽](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-can- I-DO-代替)。 - [來自評論](/ review/low-quality-posts/17813631) – manish