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

查看:155
本文介绍了在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 获取推送调用 setToolbarHidden:animated: viewDidAppear:。要隐藏工具栏,我在 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,但我想使用 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天全站免登陆