简体   繁体   中英

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!

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";

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