Alex Rivera | Logout

Programmatically pressing a UITabBar button in Xcode

Asked 2009-11-25T08:15:51.733
12

Sorry for the newbie question. I have a UITabBar in my main window view as well as an array of UINavigationControllers for each Tab. The structure is similar to the iPod app in that the main views can be seen by selecting TabBar items and then the user can drill down further with the NavigationController by pushing views to the stack.

What I would like to be able to do is to do the equivalent of pressing a TabBar button at the bottom from any of the subviews in code (i.e., change the selected property of the TabBar and display launch the first view controller for the tab).

Any help would be greatly appreciated.

Dave

Edit
Report

1 Answer

3

I'd like to reply to Prakash, but can't figure out how. Maybe I'm blocked until my score goes up.

Anyhow, I hope this helps someone:

I was doing what Prakash said, and nothing was happening. It's because to get a pointer to my app delegate, I was doing this:

AppDelegate_Phone *appDelegate = [[AppDelegate_Phone alloc] init];

When I should have been doing this:

AppDelegate_Phone *appDelegate = (AppDelegate_Phone *) [[UIApplication sharedApplication] delegate];

Newbie mistake.

answered 2010-07-03T06:05:35.670

Your Answer