ios - Observer being added after postNotification ONLY on iPhone 4S -


i have functional code works on ios >8.0 iphones >5 , ipads, pass information , call function via observers/notifications, on iphone 4s doesn't work.

through debugging, found out only while running on iphone 4s observer gets added after notification gets posted.

this happening on devices , on simulator, on ios 8 , 9, respectively.

code:

**postnotification** override func viewdidload() {     super.viewdidload()      self.registercells()      uiapplication.sharedapplication().statusbarstyle = .lightcontent      self.collectionview.delayscontenttouches = false      nsnotificationcenter.defaultcenter().addobserver(self, selector: "footerupdatecontentsize:", name: "footerupdatecontentsize", object: nil)     nsnotificationcenter.defaultcenter().addobserver(self, selector: "seasonupdatecontentsize:", name: "seasonupdatecontentsize", object: nil)      self.loaddetailtvshow() }  func registercells() {     self.collectionview.registerclass(headerdetailseriescell.self, forcellwithreuseidentifier: "headerdetailseriescell")     self.collectionview.registerclass(footerdetailseriescell.self, forcellwithreuseidentifier: "footerdetailseriescell")     self.collectionview.registerclass(seriesseasoncontentcell.self, forcellwithreuseidentifier: "seriesseasoncontentcell") }   func loaddetailtvshow() {     let id: string! = (tvshow != nil) ? tvshow!.id! : episode!.seriesid!      contentsclient().getcontentbyid(id!).then { data -> void in         let m: tvshow? = data as! tvshow?         self.tvshow = m!         self.collectionview.reloaddata()          nsnotificationcenter.defaultcenter().postnotificationname("loadedtvshowlist", object: self.tvshow)          uiview.animatewithduration(1.0, delay: 0, options: .transitionnone, animations:             {                 self.loadingview.alpha = 0.0              }, completion:nil)     } } func collectionview(collectionview: uicollectionview, cellforitematindexpath indexpath: nsindexpath) -> uicollectionviewcell {     cell = collectionview.dequeuereusablecellwithreuseidentifier("seriesseasoncontentcell", forindexpath: indexpath)      let seriescontent = cell as! seriesseasoncontentcell      seriescontent.seriescontentcell?.tvshow = self.tvshow      seriescontent.contentview.frame = cgrect(x: 0.0, y: 0.0, width: width, height: heightseason)     seriescontent.seriescontentcell?.view.frame = seriescontent.contentview.frame }  **observer**  class seriesseasoncontent  override func viewdidload() {     super.viewdidload()      self.registercells()      seasonselectedindex = 0      collectionview.reloaddata()      nsnotificationcenter.defaultcenter().addobserver(self, selector: "loadedtvshowlist:", name: "loadedtvshowlist", object: nil) }  func registercells () {     self.seasoncollection.registerclass(seasonviewcell.self, forcellwithreuseidentifier: "seasonviewcell")      self.collectionview.registerclass(episodeviewcell.self, forcellwithreuseidentifier: "episodeviewcell") }  func loadedtvshowlist(notification : nsnotification){     self.tvshow = notification.object! as? tvshow      if (tvshow?.seasons != nil && tvshow?.seasons?.count > 0)     {         self.currentseason = ((tvshow?.seasons!.objectatindex(seasonselectedindex) as? season)?.episodes)!          self.collectionview.reloaddata()         self.seasoncollection.reloaddata()     } } 

obs: im using multiple collectionviews in same view, , nib files named correctly

is there reason why iphone 4s load viewdidload method after notification has been posted?

managed solve problem. iphone 4s screen size wasn't big enough trigger cellforindex event , class/observer wasn't initiated until phone screen scrolled down.


Comments

Popular posts from this blog

html - Styling progress bar with inline style -

java - Oracle Sql developer error: could not install some modules -

How to use autoclose brackets in Jupyter notebook? -