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

        <tfoot id='OYkfe'></tfoot>

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

        • <bdo id='OYkfe'></bdo><ul id='OYkfe'></ul>
      1. iOS11 中奇怪的 uitableview 行为.带有导航推送动画的单元格向上滚动

        时间:2023-06-10

        <legend id='1LBcw'><style id='1LBcw'><dir id='1LBcw'><q id='1LBcw'></q></dir></style></legend>

            <i id='1LBcw'><tr id='1LBcw'><dt id='1LBcw'><q id='1LBcw'><span id='1LBcw'><b id='1LBcw'><form id='1LBcw'><ins id='1LBcw'></ins><ul id='1LBcw'></ul><sub id='1LBcw'></sub></form><legend id='1LBcw'></legend><bdo id='1LBcw'><pre id='1LBcw'><center id='1LBcw'></center></pre></bdo></b><th id='1LBcw'></th></span></q></dt></tr></i><div id='1LBcw'><tfoot id='1LBcw'></tfoot><dl id='1LBcw'><fieldset id='1LBcw'></fieldset></dl></div>
              <bdo id='1LBcw'></bdo><ul id='1LBcw'></ul>
              • <small id='1LBcw'></small><noframes id='1LBcw'>

                    <tbody id='1LBcw'></tbody>
                  <tfoot id='1LBcw'></tfoot>
                  本文介绍了iOS11 中奇怪的 uitableview 行为.带有导航推送动画的单元格向上滚动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我最近将一些代码迁移到新的 iOS 11 beta 5 SDK.

                  I have recently migrated some code to new iOS 11 beta 5 SDK.

                  我现在从 UITableView 中得到一个非常令人困惑的行为.tableview 本身并没有那么花哨.我有自定义单元格,但大部分只是为了它们的高度.

                  I now get a very confusing behaviour from UITableView. The tableview itself is not that fancy. I have custom cells but in most part it is just for their height.

                  当我用 tableview 推动我的视图控制器时,我会得到一个额外的动画,其中单元格向上滚动"(或者可能整个 tableview 框架被更改)并沿着推送/弹出导航动画向下滚动.请看gif:

                  When I push my view controller with tableview I get an additional animation where cells "scroll up" (or possibly the whole tableview frame is changed) and down along push/pop navigation animation. Please see gif:

                  我在 loadView 方法中手动创建 tableview 并将自动布局约束设置为等于 tableview 超级视图的前导、尾随、顶部、底部.superview 是视图控制器的根视图.

                  I manually create tableview in loadView method and setup auto layout constraints to be equal to leading, trailing, top, bottom of tableview's superview. The superview is root view of view controller.

                  视图控制器推送代码非常标准:self.navigationController?.pushViewController(notifVC, animated: true)

                  View controller pushing code is very much standard: self.navigationController?.pushViewController(notifVC, animated: true)

                  相同的代码在 iOS 10 上提供正常行为.

                  The same code provides normal behaviour on iOS 10.

                  能否请您指出错误的方向?

                  Could you please point me into direction of what is wrong?

                  我制作了一个非常简单的 tableview 控制器,我可以在那里重现相同的行为.代码:

                  I have made a very simple tableview controller and I can reproduce the same behavior there. Code:

                  class VerySimpleTableViewController : UITableViewController {
                  
                      override func viewDidLoad() {
                          super.viewDidLoad()
                  
                          self.tableView.register(UITableViewCell.self, forCellReuseIdentifier: "Cell")
                      }
                  
                  
                      override func numberOfSections(in tableView: UITableView) -> Int {
                          return 1
                      }
                  
                      override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
                          return 4
                      }
                  
                  
                      override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
                          let cell = tableView.dequeueReusableCell(withIdentifier: "Cell", for: indexPath)
                  
                          cell.textLabel?.text = String(indexPath.row)
                          cell.accessoryType = .disclosureIndicator
                  
                          return cell
                      }
                  
                  
                      override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
                          tableView.deselectRow(at: indexPath, animated: true)
                  
                          let vc = VerySimpleTableViewController.init(style: .grouped)
                  
                          self.navigationController?.pushViewController(vc, animated: true)
                      }
                  }
                  

                  编辑 2:我能够将问题缩小到我对 UINavigationBar 的自定义.我有这样的自定义:

                  EDIT 2: I was able to narrow issue down to my customisation of UINavigationBar. I have a customisation like this:

                  rootNavController.navigationBar.setBackgroundImage(createFilledImage(withColor: .white, size: 1), for: .default)

                  其中 createFilledImage 创建具有给定大小和颜色的方形图像.

                  where createFilledImage creates square image with given size and color.

                  如果我注释掉这一行,我会恢复正常行为.

                  If I comment out this line I get back normal behaviour.

                  如果您对此事有任何想法,我将不胜感激.

                  I would appreciate any thoughts on this matter.

                  推荐答案

                  这是由于UIScrollView的 (UITableView是UIScrollview的子类) new contentInsetAdjustmentBehavior 属性,默认设置为 .automatic.

                  This is due to UIScrollView's (UITableView is a subclass of UIScrollview) new contentInsetAdjustmentBehavior property, which is set to .automatic by default.

                  您可以在任何受影响的控制器的 viewDidLoad 中使用以下代码段覆盖此行为:

                  You can override this behavior with the following snippet in the viewDidLoad of any affected controllers:

                      tableView.contentInsetAdjustmentBehavior = .never
                  

                  https://developer.apple.com/documentation/uikit/uiscrollview/2902261-contentinset调整行为

                  这篇关于iOS11 中奇怪的 uitableview 行为.带有导航推送动画的单元格向上滚动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:如何使用标签栏管理容器视图中的控制器 下一篇:在透明导航栏到半透明之间转换

                  相关文章

                  <tfoot id='h3a4Z'></tfoot>

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

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

                    • <bdo id='h3a4Z'></bdo><ul id='h3a4Z'></ul>