Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change the height of a prototype cell in Xcode for tableView?

I have dragged a UITableView into my storyboard and I can fully insert info into it. But in order to customise the cell I added a prototype cell. When I change the height of it manually nothing changes in the simulator.

enter image description here

like image 956
Danial Kosarifa Avatar asked Sep 27 '17 03:09

Danial Kosarifa


People also ask

How do I change cell height in Swift?

To change the height of tableView cell in ios dynamically, i.e resizing the cell according to the content available, we'll need to make use of automatic dimension property.

How do you expand a cell in tableView?

You tap a row (it expands) You tap it again (it contracts)

How do you expand and contract height of a UITableView cell when tapped?

Animating the cell to expand and contract You supply an array of rows (indexpath) that needs to be reloaded, then the tableview will reload them by calling cellForRowAt: on these cell to layout them again, and animate the transition with the RowAnimation you passed into the with: parameter.

How do you give space between tableView cells in Swift?

The way I achieve adding spacing between cells is to make numberOfSections = "Your array count" and make each section contains only one row. And then define headerView and its height. This works great.


1 Answers

For those who come here just wanting to change the row height during design time, you can select the Table View Cell and then set the row height in the Size inspector.

enter image description here

I'm adding this answer because I found this question when I was having trouble manually dragging the cell height to something else. As the OP noted, though, this will not change the cell height at run time. The cell is auto-sized depending on its content. If you need to give it a fixed height, see the accepted answer.

like image 74
Suragch Avatar answered Sep 28 '22 16:09

Suragch