Closed jordanhbuiltbyhq closed 8 years ago
I was able to fix this by commenting out centerButtonAction(centerButton)
in tabBarController:didSelectViewController:)
and
if allowSwitch { selectedViewController = centerViewController }
in centerButtonAction
.
Is this the expected behavior?
What you want to do is actually set up your UITabBarController
to have 3 tabs.
So what you have now: tab 1 and tab 2.... they would become tab 1 and tab 3.
Then you make a dummy/placeholder/ignored UIViewController
for tab 2. You'll never switch to it, it doesn't have to actually have or do anything. But it then lets the center button work out.
Let me know if that gets things going or not.
Oh I see. Yep that works. Thanks much!
Good deal! 👍
I have set up a tab bar controller using Storyboard that contains two view controllers. I want to allow switching between these two controllers as usual. When you tap the center button I want to use target action to present a new screen modally.
When I add the center button, I set
allowSwitch
tofalse
. When I do this, tapping on the second tab does nothing - it doesn't switch to show that tab, the first tab remains selected. If I setallowSwitch
totrue
it will properly switch to the second tab, but it will also trigger the action therefore the modal appears when it shouldn't. Have I done something wrong? I'm using iOS 9.3.dispatch_async(dispatch_get_main_queue()) { let centerTabBar = self.window!.rootViewController as! HELargeCenterTabBarController centerTabBar.addCenterButton(unselectedImage: UIImage(named: "tab-send")!, selectedImage: UIImage(named: "tab-send")!, target: self, action: #selector(self.didTapSendVyte), allowSwitch: true) }