Facebook like app- cells with different size - SWIFT

1.2k Views Asked by At

and sorry for my bad english. I want to create an app like Facebook that in one tableView there are two types of cells, one for status post and other for photo post. the issue is that photo post cell and status cell has a different size. How can i make tableView with two cells that has a different size?

That's how I want it to look:
enter image description here

That's how it look:
enter image description here

2

There are 2 best solutions below

0
On

You can adjust the cellsize depending on object you want to have inside the cell.

This tutorial is what you are looking for: http://www.raywenderlich.com/87975/dynamic-table-view-cell-height-ios-8-swift

0
On

Another option might be to break your list items into multiple (fixed height) reusable rows.

eg:

#text post:
-Title row
-Text row
-Footer row

#image post:
-Title row
-Photo row
-Footer row

enter image description here

While your table source & delegate may become a bit more complex, this pattern has been proven to scale.

This article explains how facebook did it for android: https://code.facebook.com/posts/879498888759525/fast-rendering-news-feed-on-android/