jessesquires / JSQMessagesViewController

An elegant messages UI library for iOS
https://www.jessesquires.com/blog/officially-deprecating-jsqmessagesviewcontroller/
Other
11.14k stars 2.81k forks source link

Trouble Refreshing JSQMessagesViewController #391

Closed baugarten closed 10 years ago

baugarten commented 10 years ago

I'm almost certain this is user error, as I'm new to iOS development, but any help would be greatly appreciated.

I'm trying to load messages from the server when loading my subclass of the JSQMessagesViewController. I'm following the demo. Essentially, now during setupTestModel, I make an asynchronous call to the server and once complete, try to render a static list of JSQMessage.

// setupTestModel
  [self asynchronouslyLoadData:^(NSArray *messages) {
    self.messages = messages
    [self.collectionView setNeedsDisplay];
    [self.view setNeedsDisplay];
  }];

And nothing happens. I haven't changed much in the ViewController from the Demo application, just changing the seed data to load asynchronously. Apologies if how I'm trying to reload the view is incorrect. I also tried doing

  [self viewDidLoad];
  [self viewWillAppear:YES];

But got issues with View constraints.

wdcurry commented 10 years ago

Have you confirmed you have data returned?

baugarten commented 10 years ago

I made a gist of what I'm seeing

https://gist.github.com/baugarten/091569a70a9597b66f09

I only edited setupTestModel to set self.messages after the main view was rendered

baugarten commented 10 years ago

I was just looking at how others use the framework and noticed this method https://github.com/relatedcode/AwesomeChat/blob/master/Chat/ChatView.m#L108, which does solve the problem.

Apologies for not R(ing)TFM