-(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);
}
我想隐藏来自另一个 View Controller 的按钮。
最佳答案
-(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);
}
关于ios - 如何在 objective-c 中的其他 View Controller 中隐藏按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37916158/