开发人员!
我目前正在开发一个使用选项卡栏应用程序模板的应用程序。我想做什么 是模拟我的应用程序对应于第一个选项卡的起始页。
因此,当应用程序启动时,将选择第一个选项卡,并且 UITabBar 不应可见。 在这个“startview”中,有多个按钮的作用与其余选项卡类似,因此例如我按下按钮#2,第二个选项卡 View 被按下,UITabBar 再次可见。
我的问题是我有办法隐藏该栏,但 subview 没有调整为全屏。
通过使用: [self.tabBarController.tabBar setHidden:YES];
我也尝试过使用: self.hidesBottomBarWhenPushed = YES;
但它似乎没有效果,我不知道在哪里添加代码,因为我正在使用 模板。
有人知道如何使用选项卡栏应用程序模板来实现这一点吗?
我猜它应该位于: - (void)tabBarController:(UITabBarController *)tabBarController didSelectViewController: (UIViewController *)viewController
但是我已经尝试过了,但该方法从未被调用...
非常感谢, 罗伯特
最佳答案
此代码可以帮助您隐藏选项卡 Controller 并调整 View Controller 的大小。
- (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];
}
第二种方法可以帮助您在 View 中再次设置 tababr
- (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/9818591/