[英]Navigation bar button unresponsive in child view controller of UITabBarController
I instantiate my UITabBarController by calling navigationController.viewControllers = @[[self.storyboard instantiateViewControllerWithIdentifier:@"tabController"]];
我通过调用
navigationController.viewControllers = @[[self.storyboard instantiateViewControllerWithIdentifier:@"tabController"]];
实例化我的UITabBarController navigationController.viewControllers = @[[self.storyboard instantiateViewControllerWithIdentifier:@"tabController"]];
My Tab bar controller has a child view that is embedded in a navigation controller. 我的标签栏控制器具有嵌入在导航控制器中的子视图。 However the bar button (
item
) is unresponsive when I touch them (the buttons in the navigation bar). 但是,当我触摸条形按钮(
item
)时(导航栏中的按钮),它们没有响应。 I have tried logging the action but it appears as if the button is not firing at all. 我已尝试记录该操作,但它似乎根本没有触发该按钮。
The only thing that I have done differently is the way i instantiated the tab bar controller. 我唯一做的不同的事情是我实例化标签栏控制器的方式。 Am I missing something?
我想念什么吗?
I connected the navigation bar button from the storyboard to an action so it is hooked up successfully. 我将情节提要中的导航栏按钮连接到一个动作,因此它已成功连接。 Please note there is also a navigation Controller pointing to the UITabbarController not shown below.
请注意,还有一个导航控制器指向未在下面显示的UITabbarController。
The unwanted behaviour maybe because this flow (navigation controller to tabbar controller) is ill advised in the Apple HIG. 不良行为可能是因为在Apple HIG中不建议使用此流程(导航控制器到选项卡控制器)。 More information can be found here: Storyboard with NavigationController and TabController .
在此处可以找到更多信息: 带有NavigationController和TabController的情节提要 。 The solution I found was to hide the navigation bar on the navigation controller that links to the navigation bar (can be done in interface builder), then make it reappear in the new navigation controller that the tab bar links to.
我发现的解决方案是隐藏链接到导航栏的导航控制器上的导航栏(可以在界面生成器中完成),然后使其重新出现在选项卡栏链接到的新导航控制器中。 Confusing I know, I can help anyone who ever has a similar issue.
我知道,我可以为任何遇到类似问题的人提供帮助。
Is there any specific reason you are doing this: 您这样做是否有任何特定原因:
navigationController.viewControllers = @[[self.storyboard instantiateViewControllerWithIdentifier:@"tabController"]];
You can simply drag an outlet from the UITableViewController to the UINavigationController using only the Storyboard. 您可以仅使用Storyboard将插座从UITableViewController拖到UINavigationController。
I think you forgot to add the navigationItem. 我认为您忘记添加navigationItem。 In the storyboard, add a navigation Item to your viewController and move your bar button items to the navigation bar that appears on the top.
在情节提要中,将导航项添加到viewController并将条形按钮项移动到顶部显示的导航栏中。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.