Table View Content Size Not Return Correctly

[Solved] Table View Content Size Not Return Correctly | Swift - Code Explorer | yomemimo.com
Question : table view content size not return correctly

Answered by : tayyab-mubeen

override func viewWillAppear(_ animated: Bool) { super.viewWillAppear(animated) self.instructiontableview.addObserver(self, forKeyPath: "contentSize", options: .new, context: nil)
}
override func viewWillDisappear(_ animated: Bool) { self.instructiontableview.removeObserver(self, forKeyPath: "contentSize") super.viewWillDisappear(true)
}
override func observeValue(forKeyPath keyPath: String?, of object: Any?, change: [NSKeyValueChangeKey : Any]?, context: UnsafeMutableRawPointer?){ if(keyPath == "contentSize"){ if let newvalue = change?[.newKey]{ let newsize = newvalue as! CGSize self.heightofinstructioncontainerview.constant = newsize.height } }
}

Source : https://stackoverflow.com/questions/42693072/uitableview-content-size-is-not-returning-correctly-swift | Last Update : Thu, 12 May 22

Answers related to table view content size not return correctly

Code Explorer Popular Question For Swift