0

My app allows users to view another users info by tapping their avatar, at which they can block that user so that their message content is not visible.

What is the best way when returning to the chat view to clear the messages and reload them?

This would allow my blocking code to work on the fly. Currently it works when I dismiss the chat view and return but not when jump to another view and then back to the chat view.

Ive tried self.collectionView!.reloadData() but that does not do anything.

ddpishere
  • 751
  • 1
  • 8
  • 23

2 Answers2

0

All you need is to implement

override func viewDidAppear(animated: Bool) { super.viewDidAppear(animated) self.collectionView?.reloadData() }

that is called when you come back from an already instantiated view.

Dan Leonard
  • 3,325
  • 1
  • 20
  • 32
0

Call the reloadData method after a delay.

self.performSelector(#selector(self.delayReload), withObject: nil, afterDelay: 0.1)

func delayReload() {
    self.collectionView.reloadData()
}

Hope this will help you.

Sincerely, Harri.

Harri Westman
  • 140
  • 1
  • 7