La bla bla
La bla bla

Reputation: 8718

Tabbed View Controller, changing text in another view

I'm making a tabbed application, and i came across an issue.

I have a button on one tab, when it is clicked, it's doing something in the current tab. my problem is that I want to, in addition to that, it would change the text of a label in a different view (the second tab)

Can anyone give me some directions? xcode 4.2 ios 5.

Thanks alot!

Upvotes: 0

Views: 1111

Answers (1)

edc1591
edc1591

Reputation: 10182

I'm assuming you're talking about a UITabBarController. If that is the case, you can access all of the view controllers housed by the tab bar like this:

NSArray *viewControllers = [self.tabBarController viewControllers];

That gives you an array of the view controllers. Just get the view controller you want, and access the label's property and do whatever you want with it.

EDIT: Access the view controller like this:

ParkerAssistantSecondViewController *vc = [viewControllers objectAtIndex:1];
vc.label.text = @"Some Text";

Upvotes: 3

Related Questions