ios - ContentInset 在 popViewController 之后自动改变

标签 ios swift uitableview parse-platform parse-server

我有一个 2 viewController

  • itemViewController

  • 聊天 View Controller

我点击了右边的 barButton 来显示 chatViewController

之后

我点击了 backButton 返回到 itemViewController

它工作正常....除了一个问题。

当我回到 itemViewController 时...然后它自动更改了 tableView 的 contentInset

itemViewController 片段代码在这里

在viewDidLoad函数中

 tableView.rowHeight = UITableViewAutomaticDimension
        tableView.estimatedRowHeight = 450

        tableView?.contentInset = UIEdgeInsetsMake(22, 0, 0, 0)

我设置了 contentInset,因为我的应用程序有自定义导航栏高度,它比默认导航栏高度大。

enter image description here

func chat(_ sender: UITabBarItem){

        var chattingObjId = String()


    //STEP 1. is Created Chatting Room?
    PFCloud.callFunction(inBackground: "getChattingObjId", withParameters:
        ["postId":results.objectId, "from":PFUser.current()?.username!], block: { (response: Any?, error:Error?) in

            // some your code
            if error == nil {

                chattingObjId = response as! String
                print("\(chattingObjId) : Received from Server")

                let chatting = self.storyboard?.instantiateViewController(withIdentifier: "ChattingVC") as! ChattingVC

                chatting.chattingObjId = chattingObjId


                self.navigationController?.isNavigationBarHidden = false
                self.navigationController?.pushViewController(chatting, animated: true)


            }else {
                print(error?.localizedDescription as Any)
            }


    })

}

chatViewController 的代码片段如下

func back(_ sender: UITabBarItem){

    //push back
    _ = navigationController?.popViewController(animated: true)



}

enter image description here

点击后退按钮然后....

enter image description here

有差距...似乎是...22pt,这是我设置的 viewDidLoad..

为什么会这样?

enter image description here

这是我对 itemViewController 的设置。

最佳答案

我遇到了几乎相同的问题,通过取消选中“调整 ScrollView 插入”解决了这个问题。试试吧,也许它对你也有用。

关于ios - ContentInset 在 popViewController 之后自动改变,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42906422/

相关文章:

ios - 如何以编程方式在 iOS 上的当前 Crashlytics (3.14.*)/Firebase (1.10.*) 中禁用 CrashReporting

php - iPhone 4 iOS 5用UIViewController创建邮件列表的最佳方法是什么?

ios - 从 BLE 数据包中解压字节数组

ios - 如何获取iCloud中存储的图片路径?

ios - Swift:单元格 TableviewCell 中的手势不起作用

arrays - 如何在 Swift 中找到二维数组中所有元素的总和?

ios - 如何从Firebase以值的降序获取数据?

swift - 将可拖动的 NSView 与 SwiftUI 组件相结合的问题

ios - 删除后重用的UITableViewCell格式

ios - iOS 8 GM 无限循环中的 layoutSubviews