Oceandrive
Oceandrive

Reputation:

iphone sdk: set focus to different tabbar view on button click from first tabbar item

How can I set focus to different tabbar view on button click from first tabbar item? Thanks

Upvotes: 1

Views: 3537

Answers (3)

Oceandrive
Oceandrive

Reputation:

Found the solution:

HelloWorldAppDelegate *theDelegate = (HelloWorldAppDelegate*)[[UIApplication sharedApplication] delegate];
tabController = theDelegate.tabBarController;
tabController.selectedIndex = 1;

Upvotes: 4

Eldon Poncsak
Eldon Poncsak

Reputation: 1

Try this!

self.tabBarController.selectedViewController = YOURTABBARITEMController;
self.tabBarController.selectedViewController 
    = [self.tabBarController.viewControllers objectAtIndex:1];

Do NOT forget to declare YOURTABBARController in the interface (.h), synthesize it, and #import the interface file into your .m file.

Plus for me I MYTABBARController was declared as @class in the interface too.

You can get this to work for you.... and look like a KING!!!

Upvotes: 0

Deepak Dhakal
Deepak Dhakal

Reputation:

U missed the Pointer

L1AppAppDelegate *theDelegate = (L1AppAppDelegate*)[[UIApplication sharedApplication] delegate]; tabBarController = theDelegate.tabBarController; tabBarController.selectedIndex = 1;

Upvotes: 0

Related Questions