Fabio
Fabio

Reputation: 1855

How to add a separator cell/uiview between cells in a UITableView?

What's the best way to separate cells with a separator UIView or cell? Like:

31.10.2013
message: hi!
message: hey!
01.11.2013
message: hi again!

The best example is the Whatsapp chat app, they separate messages with a small separator line with the date of the messages. The "7. Mai 2013" in this screenshot: http://images.ifun.de/wp-content/uploads/2013/05/ipad-screen.jpg

I was thinking in sections but maybe it is too complex for a simple work. I also thought in adding a UILabel to the first cell of a certain day but this is not so nice.

I appreciate any help!

Upvotes: 2

Views: 428

Answers (2)

sarunw
sarunw

Reputation: 8176

I think section is a way to go, because it suit the situation which group messages with same date(section). If you use core data, that would be even easier task with NSFetchedResultsController.

Upvotes: 2

Antonio MG
Antonio MG

Reputation: 20410

You can keep record of the cells that are different and return a different cell in the cellforIndexPath, or use sections, both options seems good.

It's not a simple task, although it's not very complex once you have decided an approach.

Upvotes: 2

Related Questions