Mujtaba Mujtaba - 5 months ago 24
Objective-C Question

how to hide button in other view controller in objective c

-(void)tabBarController:(UITabBarController *)tabBarController didSelectViewController:(UIViewController *)viewController {
NewsScreen *news=[[NewsScreen alloc] initWithNibName:@"NewsScreen" bundle:nil];

if (tabBarController.selectedIndex==2) {

[news.btn setHidden: YES];

}
NSLog(@"%@", tabBarController);
}


I want to hide button which is from the other view controller.

Answer
    -(void)tabBarController:(UITabBarController *)tabBarController didSelectViewController:(UIViewController *)viewController {

            if (tabBarController.selectedIndex==2) 
            {
              NSUInteger *index=value; //assign value here
              UINavigationController *nv = [[tabBarController viewControllers] objectAtIndex:index];//index of your NewsScreen controller
              NSArray *array =[nv viewControllers];

              for (ViewController *vc in array)
              {
                if ([vc isKindOfClass:[NewScreen class]])
                {
                  [vc.btn setHidden:YES];
                }
              }

            }
            NSLog(@"%@", tabBarController);
        }
Comments