在 viewWillDisappear 期间隐藏 UINavigationController 的 UIToolbar: [英] Hiding a UINavigationController's UIToolbar during viewWillDisappear:

查看:17
本文介绍了在 viewWillDisappear 期间隐藏 UINavigationController 的 UIToolbar:的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个带有 UITableView 菜单的 iPhone 应用程序.选择表格中的行时,将相应的视图控制器按到应用程序的 uinavigationController 堆栈上.

I've got an iPhone application with a UITableView menu. When a row in the table is selected, the appropriate view controller is pushed onto the application's UINavigationController stack.

我的问题是 MenuViewController 不需要工具栏,但被推送到堆栈上的 UIViewControllers 需要.每个被推送的 UIViewController 都会调用 viewDidAppear: 中的 setToolbarHidden:animated:.为了隐藏工具栏,我在 viewWillDisappear: 中调用了 setToolbarHidden:animated:.

My issue is that the MenuViewController does not need a toolbar, but the UIViewControllers which are pushed onto the stack do. Each UIViewController that gets pushed calls setToolbarHidden:animated: in viewDidAppear:. To hide the toolbar, I call setToolbarHidden:animated: in viewWillDisappear:.

显示工具栏有效,这样当推送的视图出现时,工具栏会向上滑动并且视图会正确调整大小.但是,当按下后退按钮时,工具栏会向下滑动,但视图不会调整大小.这意味着当另一个视图过渡时,视图底部有一条黑色条带.我尝试在隐藏工具栏之前将工具栏的高度添加到视图的高度,但这会导致视图在过渡,以便仍然有一个黑条.

Showing the toolbar works, such that when the pushed view appears the toolbar slides up and the view resizes correctly. However, when the back button is pressed the toolbar slides down but the view does not resize. This means that there's a black strip along the bottom of the view as the other view transitions in. I've tried adding the toolbar's height to the height of the view prior to hiding the toolbar, but this causes the view to be animated during the transition so that there's still a black bar.

我意识到我可以管理自己的 UIToolbar,但为了方便,我想使用 UIToolbar 中内置的 UINavigationControllers.

I realise I can manage my own UIToolbar, but I'd like to use UINavigationControllers built in UIToolbar for convenience.

此论坛帖子 提到了同样的问题,但没有提到解决方法.

This forum post mentions the same issue, but no workaround is mentioned.

推荐答案

我也遇到过这个问题.就我而言,我发现在不显示窗口背景的情况下成功隐藏工具栏的唯一方法是在视图控制器的 中调用 [self.navigationController setToolbarHidden:YES animated:animated] -viewDidAppear: 方法.

I too have experienced this problem. In my case, the only way I found to successfully hide the toolbar without showing the background of the window is to call [self.navigationController setToolbarHidden:YES animated:animated] in your view controller’s -viewDidAppear: method.

这篇关于在 viewWillDisappear 期间隐藏 UINavigationController 的 UIToolbar:的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆