开发者

UITabBarController - simulate double tap on UITabBarItem

开发者 https://www.devze.com 2023-04-02 10:38 出处:网络
I have a UITabBarController, if I push to different views from开发者_开发技巧 the first UITabBarItem and I tap the first UITabBar two times then the views that were pushed are popped back.

I have a UITabBarController, if I push to different views from开发者_开发技巧 the first UITabBarItem and I tap the first UITabBar two times then the views that were pushed are popped back.

How can I simulate this exact functionality programatically?


You could implement the tabBarController:didSelectViewController: method of your UITabBarController to do this. You can manually count the number of taps on your UITabBar in the AppDelegate, and have certain conditions in the method.

For example, you could try in the .h file having an instance variable which stores the last UIViewController selected, and the time it was selected. If you then check the last time the UIViewController was called in same method, and it was a short enough period, then it would count as a double tap.

Hope that Helps!

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号