[英]Smooth scrolling with prefersLargeTitles and UITableView
I encountered a problem with the scrolling when using the prefersLargeTitles
and added UITableView
. 我在使用prefersLargeTitles
并添加了UITableView
时遇到滚动问题。
If I set the prefersLargeTitles
within a navigation controller and its root is a UITableViewController
everything is fine, scrolling of the navigation large title works the same way we can see in the system apps (in iOS 11+) . 如果我在导航控制器中设置prefersLargeTitles
并且它的根是UITableViewController
一切都很好,滚动导航大标题的工作方式与我们在系统应用程序中看到的方式相同(在iOS 11+中) 。
However, if I use a UIViewController
and add a UITableView
in it, scroll seems to act differently. 但是,如果我使用UIViewController
并在其中添加UITableView
,则滚动似乎采取不同的行为。 Navigation bar is moving more/faster than I actually scroll. 导航栏比我实际滚动更快/更快。 It just hides/shows the large title whenever I scroll into a position that just triggers it, so I end up with the totally different feeling. 只要我滚动到一个只触发它的位置,它就会隐藏/显示大标题,所以我最终会有完全不同的感觉。
Turns out that the layout is causing this problem. 原来,布局导致了这个问题。
The problem occurs if the UITableView
use Align top to: Safe Area constraint (besides the bottom, leading and trailing to Safe Area
) and is not extended under the bar. 如果UITableView
使用顶部对齐:安全区域约束(除了底部,前导和尾随Safe Area
)并且未在条形下扩展,则会出现问题。
However if I use the extended layout, align top to the superview
, I can still use the UITableView
and get the correct behaviour of the large title and its navigation bar. 但是,如果我使用扩展布局,将顶部对齐到superview
,我仍然可以使用UITableView
并获得大标题及其导航栏的正确行为。
edgesForExtendedLayout = .top
extendedLayoutIncludesOpaqueBars = true
Or use navigation bar's isTranslucent = true
which extends it too. 或者使用导航栏的isTranslucent = true
,它也可以扩展它。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.