0

I'm trying to change the tab in my Tabbar dynamically.

I've added a class for UITabBarController.

In the first Tab controller I've placed a button and on click i want to switch to the third tab at runtime.

I'm an absolute beginner so I'm not sure how this works

On click of the button I'm using

[self.tabBarController selectedIndex:2]

But i'm getting an error that says:

No visible interface declares the selector 'selectedIndex'

Nirav D
  • 71,513
  • 12
  • 161
  • 183
jamian
  • 1,544
  • 2
  • 16
  • 25
  • Possible duplicate of [Switching to a TabBar tab view programmatically?](http://stackoverflow.com/questions/5413538/switching-to-a-tabbar-tab-view-programmatically) – Pushkraj Lanjekar Jan 03 '17 at 17:52

1 Answers1

3

It is setSelectedIndex. You are mixing two syntax.

[self.tabBarController setSelectedIndex:2];

Or either you can set it like this

self.tabBarController.selectedIndex = 2;
Nirav D
  • 71,513
  • 12
  • 161
  • 183