最近因为弄个隐藏自定义的tabbar搞得一时火急火燎. 现在把他记录一下吧, 希望下次可以迅速解决.
1.首先在tabbar控制器中注册通知
@implementation TMTTabBarController
- (void)viewDidLoad {
[super viewDidLoad];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(TabBarhidden:) name:@"TabBarhidden" object:nil];
}
- 处理通知
pragma mark 通知
- (void)TabBarhidden:(NSNotification *)notification {
if ([notification.object isEqual:@"hide"]) {
self.TtabBar.hidden = YES;
}
else{
self.TtabBar.hidden = NO;
}
}
- 在要跳转的控制器中发送通知
//"设置"按钮点击事件
-
(void)didClickSettingBtn{
TMTSettingController *settingVc = [[TMTSettingController alloc] initWithStyle:UITableViewStyleGrouped];
self.settingVc = settingVc;[[NSNotificationCenter defaultCenter] postNotificationName:@"TabBarhidden" object:@"hide"];
[self.navigationController pushViewController:settingVc animated:YES];
}
/**
- 跳转回来时显现tabbar
*/
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
[[NSNotificationCenter defaultCenter] postNotificationName:@"TabBarhidden" object:@"noHidden"];
}