我有一个 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,因为我的应用程序有自定义导航栏高度,它比默认导航栏高度大。
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)
}
点击后退按钮然后....
有差距...似乎是...22pt,这是我设置的 viewDidLoad..
为什么会这样?
这是我对 itemViewController 的设置。
最佳答案
我遇到了几乎相同的问题,通过取消选中“调整 ScrollView 插入”解决了这个问题。试试吧,也许它对你也有用。
关于ios - ContentInset 在 popViewController 之后自动改变,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42906422/