Prevent automatic popToRootViewController on double-tap of UITabBarController

前端 未结 5 1944
别跟我提以往
别跟我提以往 2020-11-30 07:18

The default behavior of a UITabBarController is to pop the contained UINavigationController to the root view controller when a particular tab is tapped a second time. I have

5条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-11-30 08:10

    Here is the Swift 3 version:

    func tabBarController(_ tabBarController: UITabBarController, shouldSelect viewController: UIViewController) -> Bool {
        return viewController != tabBarController.selectedViewController
    }
    

提交回复
热议问题