jamian
jamian

Reputation: 1652

Change Tab in TabBar at runtime

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'

Upvotes: 0

Views: 289

Answers (1)

Nirav D
Nirav D

Reputation: 72410

It is setSelectedIndex. You are mixing two syntax.

[self.tabBarController setSelectedIndex:2];

Or either you can set it like this

self.tabBarController.selectedIndex = 2;

Upvotes: 3

Related Questions