ios - Resizing UIView causes child table UITableView to disappear -


i have uiview contains label, button, , uitableview populates data dynamically server. having trouble resizing parent uiview fit content after content has dynamically populated. purpose of demonstrating issue, have made background of containing uiview blue.

after populating tableview data, uiview's height not adjust causing tableview data overflow, seen in diagram below.

enter image description here

i have set bottom, leading , trailing space constraints of tableview superview, , top space constraint button. uiview has no height constraints set.

i implemented function manually recalculate height of uiview after populating content of tableview. code function below:

    func resizetofitsubviews() {      var w: cgfloat = self.frame.size.width,     h: cgfloat = 0     view in subviews {         if view.frame.origin.y + view.frame.height > h { h = view.frame.origin.y + view.frame.height }     }     self.frame.size = cgsize(width: w, height: h)  } 

this function works. uiview resizes seems right size, tableview disappears after doing so:

enter image description here

completely lost why occurs. label , button seem unaffected. either need make autolayout automatically adjusts height of uiview, or make resizing uiview not cause tableview disappear.

in view debugger, tableview returning height of 0 (while rows returning 130 expected given return in heightforrowat function).

thanks

don't adjust view frame if using auto layout.

make height constraint , adjust calculated value.

-

also might easier manually calculate height.

height = numberofrows * heightperrow


Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -