ios - How Can I Solve the Collection View Blinking Issue? (Swift) -
i'm working on collection view project uses parse backend server. , not quite sure here why collection view blinks every time gets appeared on screen.. second cell of collection view gives me blink second after view got appeared on screen, image of third cell. so, can guys me solve problem? , current file looks like..
override func viewdidappear(animated: bool) { super.viewdidappear(animated) if pfuser.currentuser() == nil { // user hasn't logged in yet showlogin() } else { // user logged in, else fetchinterests() let center = nsnotificationcenter.defaultcenter() let queue = nsoperationqueue.mainqueue() center.addobserverforname("newinterestcreated", object: nil, queue: queue, usingblock: { (notification) -> void in if let newinterest = notification.userinfo?["newinterestobject"] as? interest { if !self.interestwasdisplayed(newinterest) { self.interests.insert(newinterest, atindex: 0) self.collectionview.reloaddata() } } }) } func interestwasdisplayed(newinterest: interest) -> bool { interest in interests { if interest.objectid! == newinterest.objectid! { return true } } return false override func viewdidload() { super.viewdidload() // additional setup after loading view. if uiscreen.mainscreen().bounds.size.height == 480.0 { let flowlayout = self.collectionview.collectionviewlayout as! uicollectionviewflowlayout flowlayout.itemsize = cgsizemake(250.0, 300.0) } configureuserprofile() func fetchinterests() { let currentuser = user.currentuser()! let interestids = currentuser.interestids if interestids?.count > 0 { let interestquery = pfquery(classname: interest.parseclassname()) interestquery.orderbydescending("updatedat") interestquery.cachepolicy = pfcachepolicy.networkelsecache interestquery.wherekey("objectid", containedin: interestids) interestquery.findobjectsinbackgroundwithblock({ (objects, error) -> void in if error == nil { if let interestobjects = objects [pfobject]? { self.interests.removeall() interestobject in interestobjects { let interest = interestobject as! interest self.interests.append(interest) } self.collectionview.reloaddata() } } else { print("\(error!.localizeddescription)") } }) }
Comments
Post a Comment