1. <i id='Eodvw'><tr id='Eodvw'><dt id='Eodvw'><q id='Eodvw'><span id='Eodvw'><b id='Eodvw'><form id='Eodvw'><ins id='Eodvw'></ins><ul id='Eodvw'></ul><sub id='Eodvw'></sub></form><legend id='Eodvw'></legend><bdo id='Eodvw'><pre id='Eodvw'><center id='Eodvw'></center></pre></bdo></b><th id='Eodvw'></th></span></q></dt></tr></i><div id='Eodvw'><tfoot id='Eodvw'></tfoot><dl id='Eodvw'><fieldset id='Eodvw'></fieldset></dl></div>
    2. <tfoot id='Eodvw'></tfoot>

          <bdo id='Eodvw'></bdo><ul id='Eodvw'></ul>

        <small id='Eodvw'></small><noframes id='Eodvw'>

        <legend id='Eodvw'><style id='Eodvw'><dir id='Eodvw'><q id='Eodvw'></q></dir></style></legend>

        iOS 11 navigationItem.titleView 宽度未设置

        时间:2023-05-17
      1. <legend id='U9sQb'><style id='U9sQb'><dir id='U9sQb'><q id='U9sQb'></q></dir></style></legend>

              <i id='U9sQb'><tr id='U9sQb'><dt id='U9sQb'><q id='U9sQb'><span id='U9sQb'><b id='U9sQb'><form id='U9sQb'><ins id='U9sQb'></ins><ul id='U9sQb'></ul><sub id='U9sQb'></sub></form><legend id='U9sQb'></legend><bdo id='U9sQb'><pre id='U9sQb'><center id='U9sQb'></center></pre></bdo></b><th id='U9sQb'></th></span></q></dt></tr></i><div id='U9sQb'><tfoot id='U9sQb'></tfoot><dl id='U9sQb'><fieldset id='U9sQb'></fieldset></dl></div>
                <bdo id='U9sQb'></bdo><ul id='U9sQb'></ul>
                  <tbody id='U9sQb'></tbody>

                <small id='U9sQb'></small><noframes id='U9sQb'>

                  <tfoot id='U9sQb'></tfoot>
                • 本文介绍了iOS 11 navigationItem.titleView 宽度未设置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  限时送ChatGPT账号..

                  在 iOS11 上看到一个带有 navigationItem.titleView 的行为,其中 titleView 的宽度不是屏幕的全宽.

                  Seeing a behavior on iOS11 with a navigationItem.titleView where the width of the titleView is not the full width of the screen.

                  我有一个自定义视图,我设置为 titleView.在 iOS11 之前,视图将填充导航栏区域.但是 iOS 11 并没有调整大小来填充屏幕的宽度.

                  I have a custom view that I set as the titleView. Previous to iOS11 the view would fill the navigation bar area. But iOS 11 it is not resizing to fill the width of the screen.

                  我在设置 titleView 之前尝试设置视图的框架,但没有运气.我也尝试强制 titleViews 超级视图进行布局约束,但没有运气.

                  I've tried setting the frame of the view before setting titleView but no luck. I've tried to force the titleViews superview to layout constraints as well but no luck.

                  附上截图:

                  iOS10:

                  iOS11:

                  还有其他人经历过这种情况吗?

                  Anyone else experience this?

                  推荐答案

                  我想通了.我必须覆盖视图和文本字段的 intrinsicContentSize getter.

                  I figured it out. I had to override the intrinsicContentSize getter for the view, and the text field.

                  我将宽度设置为 CGFloat.greatestFiniteMagnitude,因此它始终与屏幕一样宽.

                  I set the width to CGFloat.greatestFiniteMagnitude so it'll always be as wide as the screen.

                  更新:

                  由于我已经在这个问题上花费了几个小时,希望其他人能够通过将所有事情紧密结合起来更快地赶上来

                  Since I've spent couple of hours on this issue, hope that some else will catch up faster by having all things tight up together

                  我创建了 TitleView 的自定义子类,名为 CustomTitleView,代码如下:

                  I've created a custom sub class of TitleView, called CustomTitleView, here's the code:

                  import UIKit
                  
                  class CustomTitleView: UIView {
                  
                    override var intrinsicContentSize: CGSize {
                      return UIView.layoutFittingExpandedSize
                    }
                  }
                  

                  我从一开始就错过的最重要的部分是:

                  and the most important part which I missed from the start was this:

                  这篇关于iOS 11 navigationItem.titleView 宽度未设置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:使用 UISearchController 时,iOS 13 UIBarButtonItem 不可点击且 UINavig 下一篇:iOS:popViewController 意外行为

                  相关文章

                • <small id='NF2GL'></small><noframes id='NF2GL'>

                      <tfoot id='NF2GL'></tfoot>

                      <legend id='NF2GL'><style id='NF2GL'><dir id='NF2GL'><q id='NF2GL'></q></dir></style></legend>
                      • <bdo id='NF2GL'></bdo><ul id='NF2GL'></ul>
                      <i id='NF2GL'><tr id='NF2GL'><dt id='NF2GL'><q id='NF2GL'><span id='NF2GL'><b id='NF2GL'><form id='NF2GL'><ins id='NF2GL'></ins><ul id='NF2GL'></ul><sub id='NF2GL'></sub></form><legend id='NF2GL'></legend><bdo id='NF2GL'><pre id='NF2GL'><center id='NF2GL'></center></pre></bdo></b><th id='NF2GL'></th></span></q></dt></tr></i><div id='NF2GL'><tfoot id='NF2GL'></tfoot><dl id='NF2GL'><fieldset id='NF2GL'></fieldset></dl></div>