I want to make a chat application in swift. Can anyone tell me how to make the UI for chat cells. I know the coding is to be done in cellforRowAtIndexPath, but I don't know the exact way. And the chat cell should be in bubbles? Help me please with sample code?
Asked
Active
Viewed 1,435 times
-4
-
You may want to check this library [JSQMessages](https://github.com/jessesquires/JSQMessagesViewController) – u54r Dec 31 '15 at 16:51
-
Thanks for the info. This library is good but I want to create my own chat cells. – Dinker Malhotra Dec 31 '15 at 16:58
-
This is very general. Show us some code you have written and where you are stuck or something specific you are having trouble with. SO isn't a free coding service :) – boidkan Jan 01 '16 at 01:33
1 Answers
0
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell
{
if (indexPath.section % 2 != 0)
{
let cell = tableView.dequeueReusableCellWithIdentifier("Cell", forIndexPath: indexPath) as! RightTableViewCell
if ((array.valueForKey("msgtxt").objectAtIndex(indexPath.section) as? String) != nil)
{
cell.rightLbl.text = self.array.valueForKey("msgtxt").objectAtIndex(indexPath.section) as? String
}
return cell
}
else
{
let cell = tableView.dequeueReusableCellWithIdentifier("LeftCell", forIndexPath: indexPath) as! LeftTableViewCell
if ((array.valueForKey("msgtxt").objectAtIndex(indexPath.section) as? String) != nil)
{
cell.leftChatLbl.text = self.array.valueForKey("msgtxt").objectAtIndex(indexPath.section) as? String
}
return cell
}
}
This is what I am doing but it only shows one cell with the same values

Dinker Malhotra
- 37
- 1
- 10