简体   繁体   中英

What is the default “touch” event on the Apple UITabBarItem class?

I'm doing a custom TabBar by adding subviews on top of the default tabBar and trigerring the selected event programmatically. It works well but the problem is that my tabBar has not exactly the same behaviour as the Apple one : On the Apple default one, if you touch without releasing (touch down) it will select the tab, but not immediately when you touch (may be 0.2sec later).

  • If I put a Touch Down event on my custom TabBar, it trigger the tab immediately.
  • If I put a Touch Up Inside event, it trigger only on release...

So, what is the touch event that Apple is using in his TabBarItem class (or may be a parent class) ?

(I supposed it was a Touch Down , but if it is, why is there this kind of "delay" on the event ?)

Thanks.

It is probably using UILongPressGestureRecognizer. For example:

UILongPressGestureRecognizer *longPressGR = [[UILongPressGestureRecognizer alloc]
    initWithTarget:self action:@selector(longPressDetected:)];
longPressGR.delegate = self;
longPressGR.minimumPressDuration = 1.0;
[yourView addGestureRecognizer:longPressGR];

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM