本blog除部分譯文外,全部內容均爲原創,若有雷同,算我抄你:-)git
問題來自於iOS UIButton 的 touchDown 事件這篇帖子。簡單地說,在設置github
objcdetailVC.hidesBottomBarWhenPushed = YES;
以後,放一個view在tabbar原來的位置上,再在view上添加一個button,像這樣
爲button添加touchDown action,當按住button的左下角區域時,action沒有被觸發。segmentfault
iOS 7或以上,真機調試。ide
先查看HitTest的結果,button實例被正確地返回了。這說明button並無被透明的view所遮蓋。
接着,override button的touchesXXX方法。當按下button的左下角時,touchesBegan等4個方法徹底沒有被調用到。參考下圖
應該存在一個gesture recognizer,而且delaysTouchesBegan設置爲YES。ui
delaysTouchesBegan (default of NO)—Normally, the window sends touch objects in the Began and Moved phases to the view and the gesture recognizer. Setting delaysTouchesBegan to YES prevents the window from delivering touch objects in the Began phase to the view. This ensures that when a gesture recognizer recognizes its gesture, no part of the touch event was delivered to the attached view. Be cautious when setting this property because it can make your interface feel unresponsive.this
考慮當前場景,應該是滑動返回手勢搗的鬼。稍微驗證一下spa
objc- (void)viewDidLoad { //Other codes here NSLog(@"%d", self.navigationController.interactivePopGestureRecognizer.delaysTouchesBegan); }
獲得結果
那麼答案就很明顯了。調試
objcself.navigationController.interactivePopGestureRecognizer.delaysTouchesBegan = NO;
Placing a UIButton in the same space as UITabBar (When hidden)orm