Flipped cell when overriding tableView cellForRow method

I have to implement a lot of different types of cells. For each cell, I’m passing the SBDBaseMessage to know in which position the respective cell will be presented.

I have a SBUChannelViewController subclass, in which I override cellForRow method like that:

 override public func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) { 
      (...)
      return MyCustomChatCell()
 }

Cell creation works perfectly, I’ve instantiated my SBUBaseMessageCell subclass and called the configure(message: _, position: _, hideDateView: _, receiptState: _) method. But here’s the glitch: my cells flipped. Crazy right?

For now I’m doing this workaround:
layer.setAffineTransform(.init(scaleX: 1, y: -1))

But I think that’s an SDK bug.

Here’s my custom files, that you can check:
DMSBPaymentCardCell.swift (4.5 KB)
DMSBChatViewController.swift (5.8 KB)

its not actually glitch but you have to transform up side down to display properly on channel view. The reason is because tableview itself is already up side down (its pretty normal on chat view). I think we need to clearly state this on documentation. Thanks for the feedback tho!

@Woo, could you elaborate the reason for the table view being upside down? It is not clear for us.

Also, for now, if you can share any material exploring the subject, it will be welcomed.

1 Like

The reason why tableview is up side down is because it is more convenient to insert latest message at the top rather than at the bottom of tableview. So when you scroll down (attempting to read previous message), we append newly fetched previous messages to the list so it naturally displays on the bottom of the tableview (though it seems on top of the view because its up side down). Thats one way to implement chat view. You can find more information on google (here one https://blog.kulman.sk/filling-uitableview-from-bottom-top/)

1 Like