简体   繁体   English

NavigationBar 喜欢LargeTitle 不起作用

[英]NavigationBar prefersLargeTitle not working

Using iOS 13.3,使用 iOS 13.3,

I observe a strange behaviour of the navigationBar.我观察到导航栏的奇怪行为。 If dragging up, the navigationBar contracts.如果向上拖动,navigationBar 会收缩。 (see video) (见视频)

Don't worry about the tabs that are part of the navigationBar.不要担心作为导航栏一部分的选项卡。 The strange behaviour also happens without them.没有它们也会发生奇怪的行为。 And also the fact that the ViewController presents in a modal sheet is irrelevant - the strange contraction behaviour also happens in a classic view.而且 ViewController 出现在模态表中的事实是无关紧要的 - 奇怪的收缩行为也发生在经典视图中。 So far, I only knew this contracting behaviour from a SearchBar.到目前为止,我只从 SearchBar 知道这种收缩行为。 But no such is present here.但这里没有这样的东西。

How can I always keep the navigationBar at a fixed large size ?如何始终将导航栏保持在固定的大尺寸?

在此处输入图片说明

I tried without success....我试过没有成功....

navigationController?.navigationBar.prefersLargeTitles = true
navigationItem.largeTitleDisplayMode = .always

I finally found the solution:我终于找到了解决方案:

Since there was a tableView in the screen, the following was needed to prevent the contracting of the navigationBar:由于屏幕中有一个tableView,因此需要以下内容来防止navigationBar的收缩:

tableView.isScrollEnabled = false

If your navigationBar has a custom height or for other reasons, you can also set the tableView's Insets to place it downwards like this:如果您的导航栏具有自定义高度或出于其他原因,您还可以设置 tableView 的 Insets 将其向下放置,如下所示:

tableView.contentInset = UIEdgeInsets(top: 90.0, left: 0.0, bottom: 0.0, right: 0.0)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 NavigationBar BACK按钮不起作用 - NavigationBar BACK button not working 在推上隐藏导航栏不起作用 - Hide navigationBar on push not working 将自定义视图添加到 NavigationBar 不起作用? - Adding custom view into NavigationBar not working? UITapGestureRecognizer无法在navigationBar titleView中的UIView上使用? - UITapGestureRecognizer not working on UIView in the navigationBar titleView? 设置自定义NavigationBar后,Segue无法正常工作 - Segue not working after setting up custom navigationBar 在iOS7中自定义navigationBar - 标题颜色不起作用 - Customizing navigationBar in iOS7 - title color not working navigationController?.navigationBar.isUserInteractionEnabled无法正常工作 - navigationController?.navigationBar.isUserInteractionEnabled not working as expected 导航栏中的 SwiftUI SF 符号按钮不起作用 - SwiftUI SF Symbols Button in NavigationBar not working NavigationBar 按钮单击区域无法正常工作(图像不可单击) - NavigationBar Buttons Click Area not working properly (Image is not clickable) CapsPageMenu 隐藏 TableView 上的 NavigationBar 从子 UIViewController 滚动不起作用 - CapsPageMenu Hide NavigationBar on TableView Scroll from child UIViewController not working
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM