简体   繁体   中英

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'

It is setSelectedIndex . You are mixing two syntax.

[self.tabBarController setSelectedIndex:2];

Or either you can set it like this

self.tabBarController.selectedIndex = 2;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM