How to refresh UItableViewCell Auto Layout in UItableViewController when I change Height or Width in Swift? -


i'm working on swift project use uitableview. fill tableview using delegate methods :

  • override func collectionview(collectionview: uicollectionview, numberofitemsinsection section: int) -> int
  • override func collectionview(collectionview: uicollectionview, cellforitematindexpath indexpath: nsindexpath) -> uicollectionviewcell
  • dequeuereusablecellwithreuseidentifier
  • etc,

and un use collectionview.reloaddata() when model change (add/remove item).

my cells, inside tableview can have different size in function number of item inside model. lie :

func collectionview(collectionview: uicollectionview, layout collectionviewlayout: uicollectionviewlayout, sizeforitematindexpath indexpath: nsindexpath) -> cgsize{     var size = cgsize(width: 0,height: 0)      if timermanager.sharedinstance.timers.count < 2 {         size = collectionview.frame.size     } else if timermanager.sharedinstance.timers.count == 2 {         size = cgsize(width: collectionview.frame.size.width,height: collectionview.frame.size.height/2)     } else if  timermanager.sharedinstance.timers.count == 3 {         if indexpath.row < 2 {             size = cgsize(width: collectionview.frame.size.width/2,height: collectionview.frame.size.height/2)          } else {             size = cgsize(width: collectionview.frame.size.width,height: collectionview.frame.size.height/2)         }      } else {         size = cgsize(width: collectionview.frame.size.width/2,height: collectionview.frame.size.height/2)     }      return size } 

but problem : new cells have auto layout sizet old cells didn't refreshed. more on model changed when view tableview is not displayed.

this happened on screen : screens

i try use different ways force refresh, ask :

  • setneeddisplayforeach cell force re draw (and overriding draw check if called)
  • reloaddata when on viewwillappear
  • setneedsupdateconstraints, setneedslayout on cell

but nothing solve problem !

a friend pure ios developer @ work tell me there problem on ios 8 auto layout. perhaps it's linked ?

i hope can have ideas or solution here 😊

(i hope english isn't bad understand me, it's not native speaking language)


Comments

Popular posts from this blog

javascript - Any ideas when Firefox is likely to implement lengthAdjust and textLength? -

matlab - "Contour not rendered for non-finite ZData" -

delphi - Indy UDP Read Contents of Adata -