简体   繁体   English

iOS-标签栏UIView

[英]iOS - Tab bar UIView

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. 如果要响应UITabBarControllerDelegate ,则可以使用以下方法。

- (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. 这样,您可以在控制器级别而不是viewAppearance级别进行控制。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM