I'm developing an app with tab bar, having three different tabs. On the second tab I want to hide some controls (textfields & labels) when each tab lost its focus ie when user goes to another tab.
Is there any specific method to do so.
By the way, I know the code for hiding controls.
[anylbl setHidden:YES];
I just want to know methods for view lost focus.
For firing events when closing the view you can use:
-(void) viewWillDisappear:(BOOL)animated
{
[super viewWillDisappear:animated];
_yourLabel.hidden = YES;
_yourImageView.hidden = YES;
}
You can also use:
-(void) viewDidDisappear:(BOOL)animated
{
[super viewDidDisappear:animated];
_yourLabel.hidden = YES;
_yourImageView.hidden = YES;
}
If you want to respond to the UITabBarControllerDelegate
, then you have these methods.
- (BOOL)tabBarController:(UITabBarController *)tabBarController shouldSelectViewController:(UIViewController *)viewController NS_AVAILABLE_IOS(3_0);
- (void)tabBarController:(UITabBarController *)tabBarController didSelectViewController:(UIViewController *)viewController;
This way you can control this on a controller level rather than a viewAppearance level.
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.