我正在设计一个应用程序,它在选项卡栏中有超过4个选项,所以我想做的就是在推送任何 View 时隐藏选项卡栏,并在弹出 View 时再次显示它,我尝试了 hidesbottomwhenpushed 但没有'不为我工作。请帮忙
最佳答案
使用此功能
- (void) hideTabBar:(UITabBarController *) tabbarcontroller
{
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.5];
for(UIView *view in tabbarcontroller.view.subviews)
{
if([view isKindOfClass:[UITabBar class]])
{
[view setFrame:CGRectMake(view.frame.origin.x, 480, view.frame.size.width, view.frame.size.height)];
}
else
{
[view setFrame:CGRectMake(view.frame.origin.x, view.frame.origin.y, view.frame.size.width, 480)];
}
}
[UIView commitAnimations];
}
当你调用这个函数时
[self hideTabBar:self. tabbarcontroller];
当你想显示 tabbarcontroller 时使用这个函数
- (void) showTabBar:(UITabBarController *) tabbarcontroller {
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.5];
for(UIView *view in tabbarcontroller.view.subviews)
{
NSLog(@"%@", view);
if([view isKindOfClass:[UITabBar class]])
{
[view setFrame:CGRectMake(view.frame.origin.x, 431, view.frame.size.width, view.frame.size.height)];
}
else
{
[view setFrame:CGRectMake(view.frame.origin.x, view.frame.origin.y, view.frame.size.width, 431)];
}
}
[UIView commitAnimations];
}
关于iphone+在推送任何 View 时隐藏标签栏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10106017/