soffes/ssmessagesviewcontroller

Can only display 12 bubbles at a time?

markrickert opened this issue · 5 comments

I'm having an issue with adding more than 12 bubbles to a chat window.

I took the demo project and changed the values of the display and as you can see, after 12, it starts over again at 1.

Any idea on how to fix this? Even a Hint, and i can likely do it myself, but i'm stuck in a rut with debugging this.

Example

It also does some WEIRD things when you scroll up and down... all the cell positions and numbers change... I think there's an issue with the cell re-use and dequeueing

So it works perfectly if i change line 121 of SSMessagesViewController.m from

cell = [[[SSMessageTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier] autorelease];

to

cell = [[[SSMessageTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:nil] autorelease];

Essentially removing the cell re-use, which is horrible for memory management. So this issue is definitely related to the reuse of the cells.

Weird. Definitely a bug. I'll look into it when I get time. Feel free to fork, fix, and send a pull request :)

Add calls to:

[_bubbleView setNeedsDisplay];

so they become:

  • (void)setMessageStyle:(SSMessageStyle)aMessageStyle {
    _bubbleView.messageStyle = aMessageStyle;
    [_bubbleView setNeedsDisplay];
    }
  • (void)setMessageText:(NSString *)text {
    _bubbleView.messageText = text;
    [_bubbleView setNeedsDisplay];
    }

In the SSMessageTableViewCell setters for messageStyle and messageText.

I'd submit a patch, but I don't have a good fork, sorry.

Fixed and pull request sent. Thanks andy!