哇,我现在也遇到了同样的问题,非常痛苦,网上没有关于它的信息。
无论如何,对我来说,一个简单的解决方法是更改当前视图的 Frame,将 y 坐标向上移动,并使标签栏的高度变大。如果在将新视图推送到导航控制器后直接完成,这可以解决问题。此外,之后无需修复 Frame(再次显示视图时必须更新它)。
单触代码:
UIViewController viewControllerToPush = new MyViewController();
viewControllerToPush.HidesBottomBarWhenPushed = true; // I had this in the MyViewController's constructor, doesn't make any difference
this.NavigationController.PushViewController(viewControllerToPush, true);
float offset = this.TabBarController.TabBar.Frame.Height;
this.View.Frame = new System.Drawing.RectangleF(0, -offset, this.View.Frame.Width, this.View.Frame.Height + offset);
Objective C 代码(未经测试,只是 monotouch 代码的翻译):
UIViewController *viewControllerToPush = [MyViewController new];
viewControllerToPush.hidesBottomBarWhenPushed = YES; viewControllerToPush.hidesBottomBarWhenPushed = YES;
float offset = self.tabBarController.tabBar.frame.size.height; float offset = self.tabBarController.tabBar.frame.size.height;
self.view.frame = CGRectMake(0, -offset, self.view.frame.width, self.view.frame.height + offset); self.view.frame = CGRectMake(0, -offset, self.view.frame.size.width, self.view.frame.size.height + offset);