2014-08-27 60 views
4

我在我的应用程序上使用TabBarController,在其中一个主视图(aViewController)中,我推入另一个控制器(bViewController),并使用self.tabBarController隐藏TabBar。 tabBar.hidden = YES;隐藏TabBar后无法触及TabBar后面的区域

bViewController在tabBar所在的位置有一个按钮,并且它不捕获触摸事件。

我已经尝试将按钮放置在bViewController的不同位置,并且tabBar本应该是的区域是触摸事件未检测到的唯一位置。

我试过在tabBarController之外使用bViewController,它工作正常。 任何帮助,将不胜感激。

编辑:

当我按下aViewController一个按钮,我叫

self.tabBarController.tabBar.hidden=YES; 
[self performSegueWithIdentifier:@"aViewToBView" sender:self]; 

aViewToBview是宣布对故事板

+0

你现在bViewController模态或推呢? – cph2117 2014-08-28 01:19:09

+0

这是一个推广segue – gomezluisj 2014-08-28 15:04:38

+0

你可以发布你的代码? – cph2117 2014-08-29 14:27:33

回答

1

出于某种原因,你不能碰下面的意见的推动SEGUE标签栏。

但是,如果您隐藏标签栏并向其中添加子视图,则视图可以接收用户交互!

这为我工作:

// Create a button that is at the very bottom of the screen 
CGFloat buttonHeight = 45.0f; 
UIButton *finishButton = [[UIButton alloc] initWithFrame:CGRectMake(
      0, 
      self.view.frame.size.height - self.tabBarController.tabBar.frame.size.height - buttonHeight, 
      self.view.frame.size.width, 
      buttonHeight)]; 
//...more initialization of the button... 

//Here is our solution: 
[self.tabBarController.view addSubview:finishButton]; 
+0

这不是我的最佳解决方案,但它的工作原理,谢谢。 – gomezluisj 2014-12-28 21:17:58

+0

@gomezluisj为什么它不是最好的解决方案?你能详细说明吗? – 2014-12-29 17:54:57

+0

以编程方式创建按钮意味着我无法使用我的故事板约束,所以我需要以编程方式将它们设置为太痛苦。 – gomezluisj 2014-12-29 20:45:17