iOS 11大标题导航栏未折叠 [英] iOS 11 large-title navigation bar not collapsing
问题描述
可可触摸WWDC视频中的新内容中的苹果人新的大标题导航栏将神奇地挂接到基础视图控制器的顶级滚动视图中,并在上下滚动时自动折叠/扩展自身. (神奇地",他可能意味着他们无法以一种可用的方式将这一功能猴子化到已经令人尴尬的UINavigationController
-UINavigationBar
-UINavigationitem
API中,因此,他们不得不求助于某些启发式选择幕后滚动视图)
The Apple guy in the What's new in Cocoa Touch WWDC video said that the new large-title navigation bar will magically hook into the top-level scroll view of the underlying view controller and collapse/expand itself automatically while scrolling up and down. (And by "magically", he probably meant that they failed to monkey patch this functionality into the already embarassing UINavigationController
-UINavigationBar
-UINavigationitem
APIs in a usable way, so they had to resort to hooking into some heuristically chosen scroll view behind the scenes)
即使我准备好如果我稍微偏离基本的UINavigationController
+ UITableView
/UICollectionView
设置,这种自动"折叠/展开也不起作用,即使在这种最简单的情况下,它似乎也不会不能按预期工作.
Even though I was prepared that this "automatic" collapse/expand wouldn't work if I deviate the slightest from the basic UINavigationController
+ UITableView
/UICollectionView
setup, it seems that even in this simplest case it doesn't work as expected.
这就是我所拥有的:
包含UINavigationController
的UITabBarController
,其中包含UIViewController
的UIViewController
作为其view
.点击表中的第一个单元格将在导航堆栈中推送第二个视图控制器:
A UITabBarController
which contains a UINavigationController
, which contains a UIViewController
, which has a UITableView
as its view
. Tapping the first cell in the table will push a second view controller on the navigation stack:
没有代码,只有情节提要.
No code, just the storyboard.
我已经在导航栏中选中了喜欢大标题" 以激活大标题.现在,如果我运行该应用程序并在表格视图上向上/向下滚动,则导航栏保持不变-大-尺寸;它不会崩溃:
I've checked "Prefers large titles" for the navigation bar to activate large titles. Now, if I run the app and scroll up/down on the table view, the navigation bar stays the same - large - size; it doesn't collapse:
但是,我发现如果将第二个视图控制器的导航项设置为使用小导航栏(将大标题" 设置为值从不" ),然后,如果我打开该页面并向后浏览,则交互式折叠会神奇地开始在第一页上工作:
However, I've found that if I set the second view controller's navigation item to use the small navigation bar (by setting "Large Title" to the value "Never"), then if I open that page and navigate back, the interactive collapse magically starts working on the first page:
我在这里缺少什么吗?还是此功能无法正常工作?这是我正在使用的示例项目: https://github.com/tzahola/iOS-11-大型标题导航栏
Am I missing something here, or is this feature not working properly? Here's the sample project I'm using: https://github.com/tzahola/iOS-11-Large-Title-Navigation-Bar
顺便说一句,我使用的是正式发布的iOS 11,而不是Beta.
And by the way, I'm using the officially released iOS 11, not the betas.