2

here is resume of my app:

  • I have tab bar. When user tap on the tabbar item
  • appropriate view controller is presented by "slide-to-side" animation (like in iP homescreen).

Code is in method tabBarController(tabBarController: UITabBarController, shouldSelectViewController viewController: UIViewController) -> Bool.

  • I have alert. When user tap on button, I want to direct him to the specific tab. But when I use self.selectedIndex = #, VC is showen, but without animation. Is there any way to achieve same action like tap on item? Thank you
Lachtan
  • 4,803
  • 6
  • 28
  • 34

1 Answers1

9

Programmatically selecting the tab doesn't trigger any delegate methods. This is true of any control. Since you explicitly chose to do something, you already know you did it. You don't need a delegate method to tell you. This is by design and it is a good thing.

There is a simple solution. Put whatever animation code is inside the delegate method into its own method. Then call that method from the delegate method. Now you can also call that new method when you call self.selectedIndex = #.

rmaddy
  • 314,917
  • 42
  • 532
  • 579
  • Right, I just needed little bit more work around. But I did basically what you said. Thank you:) – Lachtan May 04 '16 at 09:10