I have a UITabBar Controller having three view controller. I am trying to refresh my two view controller which are map view controller and tableview controller; from third view controller with an action of slide. Here what i have tried:
- (IBAction)actionMySlider:(id)sender{
NSNumberFormatter* numberFormatter = [[NSNumberFormatter alloc] init];
[numberFormatter setFormatterBehavior: NSNumberFormatterBehavior10_4];
[numberFormatter setNumberStyle: NSNumberFormatterDecimalStyle];
NSString *numberString = [numberFormatter stringFromNumber: [NSNumber numberWithInteger: mySlider.value]];
MetreLabel.text = [NSString stringWithFormat:@"Yarı Çap(Re): %@(m)",numberString];
[(AppDelegate *)[[UIApplication sharedApplication] delegate] setVariable:[NSString stringWithFormat:@"%f",mySlider.value]];
ViewController1 *VC1=[[ViewController1 alloc]init];
[VC1 viewDidLoad];
ViewController2 *VC2 = [[ViewController1 alloc]init];
[VC2 viewDidLoad];
}
Thank you for your answers.
EDIT According to answers my approach is implementing a for loop at my TabBar.m. But i have some issues while implementing this.
for (UIViewController *v in self.tabBar.viewControllers)
{
UIViewController *vc = v;
if ([v isKindOfClass:[UINavigationController class])
{
vc = [v visibleViewController];
}
if ([vc isKindOfClass:[MyViewController class]])
{
MyViewController *myViewController = vc;
[vc doSomething];
}
}
- problem: what should i write instead of viewcontrollers at self.tabBar.viewControllers. I could not figure out that.
- problem: after i implement that for loop in a method in TabBar.m, will i be able to reach my viewcontrollers from another viewcontroller via calling that method?