Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Should I use UITableView or UICollectionView when building a chat app? [closed]

I'm trying to build a chat app like the native Messages app/Whatsapp.

The design is a little bit different than the native chat bubbles (rectangle messages view instead of bubbles) but I guess the basics are the same. Of course the messages should start from the bottom of the screen like any chat app, and in the bottom there should be a "new message" textField.

Should I use UITableView or UICollectionView for this purpose?

Thank you!

like image 716
FS.O6 Avatar asked Dec 13 '25 09:12

FS.O6


1 Answers

I just finished shipping a chat app and went through this exact question when building the architecture. This isn't a hot take.

I made the mistake at first to go with UITableView only to realize halfway that UICollectionView is way more powerful. (UICollectionView even has a tableLayout if you want to use it this way).

I realized this after studying the other chat libraries available like JSQMessagesViewController, MMTextureChat, MessageKit etc.

UITableView is good but soon enough you'll run into performance and customization issues like I did.

As for showing the messages from the bottom, the trick is to flip the view. That way when you call insert(atIndexPath:) the item shows up at the bottom.

Hope it helps.

like image 100
ahbou Avatar answered Dec 15 '25 05:12

ahbou



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!