gpt4 book ai didi

iphone - 标签栏在导航时隐藏

转载 作者:行者123 更新时间:2023-11-29 13:24:09 26 4
gpt4 key购买 nike

默认情况下,我的项目中有四个选项卡 第一个选项卡被选中,它是 Home Class 当用户通过选择任何选项卡导航到任何其他类时,我必须检查时间,如果用户登录我的应用程序,那么他将导航到他选择的类,否则他将移动到登录屏幕。

 if(appDelegate.sessionId==0)
{

Login *objLogin=[[[Login alloc] initWithNibName:@"Login" bundle:nil] autorelease];

[self.navigationController pushViewController:objLogin animated:YES];

}
else
{
CreatePoll *objLogin=[[[CreatePoll alloc] initWithNibName:@"CreatePoll" bundle:nil] autorelease];
[self.navigationController pushViewController:objLogin animated:YES];

}

如果我导航到登录屏幕,我的选项卡栏会被隐藏,当我调试代码时,我发现 Create Poll 类也在后台被调用,我检查了这个 link显示隐藏但无法成功的标签栏。请帮助我,我从过去 3 天开始就遇到了这个问题。在登录屏幕中看不到我的标签栏。请帮忙

最佳答案

只需在 viewWillAppear: 方法中编写此代码即可隐藏和显示 UITabBar

AppDelegate *appDelegate = (AppDelegate *)[UIApplication sharedApplication].delegate;
[appDelegate.tabBarController.tabBar setHidden:NO];

更新:

AppDelegate.m 文件中发布这些方法,当您想要显示和隐藏 Tabbar 时创建 AppDelegate 对象并调用此方法

- (void) hideTabBar:(UITabBarController *) tabbarcontroller {

int height = 480;

[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.3];

for(UIView *view in tabbarcontroller.view.subviews) {
if([view isKindOfClass:[UITabBar class]]) {
[view setFrame:CGRectMake(view.frame.origin.x, height, view.frame.size.width, view.frame.size.height)];
}
else {
[view setFrame:CGRectMake(view.frame.origin.x,view.frame.origin.y, 320, 436)];
}
}
[UIView commitAnimations];
}

- (void) showTabBar:(UITabBarController *) tabbarcontroller {

int height = 480;

[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.3];

for(UIView *view in tabbarcontroller.view.subviews) {

if([view isKindOfClass:[UITabBar class]]) {
[view setFrame:CGRectMake(view.frame.origin.x, height, view.frame.size.width, view.frame.size.height)];
}
else {
[view setFrame:CGRectMake(view.frame.origin.x, view.frame.origin.y, view.frame.size.width, height)];
}
}

[UIView commitAnimations];
}

关于iphone - 标签栏在导航时隐藏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13581838/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com