swift - Call reloadData() after a dismissViewController -


i have collectionview controller collectionview populated database. in controller have reloaddata() in 'viewdidappear' , 'viewwillappear' functions.

the collectionview controller has modal segue gameviewcontroller. after 'game' finished in gameviewcontroller, database updated (this works) , modal dismissed collectionview controller.

func gameover() {     self.dismissviewcontrolleranimated(true, completion: nil) } 

however despite 'viewdidappear' , 'viewwillappear' being called (i confirm println()) when gameviewcontroller dismissed, collectionview data not reload. updated database data isn't shown in collectionview.

the collectionview data reload if dismiss collectionview controller, , reopen it.

how ensure collectionview controller - reloaddata() - called after dismissing gameviewcontroller?

code:

class gameviewcontroller: uiviewcontroller {  var collectionview: levelscollectionviewcontroller!  override func viewdidload() {     super.viewdidload()      // code not related question - creates game scene  }  override func viewdiddisappear(animated: bool) {     collectionview.reloaddata() }  func gameover() {     self.dismissviewcontrolleranimated(true, completion: nil) }    class levelscollectionviewcontroller: uicollectionviewcontroller {  // code setting cells  override func viewwillappear(animated: bool) {     super.viewwillappear(animated)     println("viewwillappear")      self.collectionview!.reloaddata()     self.collectionview!.setneedsdisplay()     }  override func viewdidappear(animated: bool) {     super.viewwillappear(animated)     println("viewdidappear")             self.collectionview!.reloaddata()     self.collectionview!.setneedsdisplay() } } 

update:

the println() viewwillappear & viewdidappear printed in console after dismissviewcontroller, collectonview data isn't reloaded.

the database collectionview taken updated (done function called before gameover().

i tried method suggested below of having reference uiviewcontroller , calling reloaddata on viewdiddisappear, nothing happens.

check make sure data source being updated (a few println's in viewdidappear() help) - in addition, try storing reference collectionview controller , calling reloaddata() on in viewwilldisappear() method of gameviewcontroller.


Comments

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -

How to provide Authorization & Authentication using Asp.net, C#? -