Swift-uitableviewcell Countdown Reuse Solution
Effect
Source
Https://github.com/YouXianMing/Swift-Animations
////Countdowntimercontroller.swift//swift-animations////Created by youxianming on 16/9/4.//copyright©2016 year youxianming. All rights reserved.//Import UIKitclassCountdowntimercontroller:normaltitleviewcontroller, Uitableviewdelegate, Uitableviewdatasource {var timesArray : [Celldataadapter]!var tableview:uitableview!var timer:gcdtimer=Gcdtimer (inQueue:GCDQueue.mainQueue)Overridefunc Setup () {Super.setup ()//Create data source.Timesarray =[Celldataadapter] () func Add (title title:string, countdowntime:int) {Timesarra Y.append (Countdowntimecell.adapter (Data:timemodel (Title:title, Countdowntime:countdowntime))} A DD (title:"youxianming", Countdowntime:20034) Add (title:"Aaron", Countdowntime: to) Add (title:"Nicholas", Countdowntime:1003) Add (title:"Quentin", Countdowntime:394) Add (title:"Samirah", Countdowntime:345345) Add (title:"Serafina", Countdowntime:233) Add (title:"Shanon", Countdowntime:4649) Add (title:"Sophie", Countdowntime:3454) Add (title:"Steven", Countdowntime:54524) Add (title:"Saadiya", Countdowntime:235) //Create TableView.TableView = UITableView (frame: (Contentview?. Bounds)!) TableView.Delegate=Self tableview.datasource=Self tableview.separatorstyle= . None Tableview.rowheight= -Contentview?. Addsubview (TableView)//Register cell.Countdowntimecell.registerto (TableView)//Timer event.weak var wself =Self timer.Event({ for(_, DataAdapter)inchwself!. Timesarray.enumerate () {ifLet model = Dataadapter.data as?Timemodel {Model.countdown ()}} Defaultnotificationcenter.postmessageto (NotificationEvent.CountDownTimeCellCountDown.Message ())}, Tim Eintervalwithseconds:1.0) Timer.start ()} func TableView (Tableview:uitableview, numberofrowsinsection section:int)-Int {returnTimesarray.count} func TableView (Tableview:uitableview, Cellforrowatindexpath Indexpath:nsindexpath) -UITableViewCell {returnTableview.dequeuecellandloadcontentfromadapter (Timesarray[indexpath.row], Indexpath:indexpath)} func tabl Eview (Tableview:uitableview, Willdisplaycell Cell:uitableviewcell, Forrowatindexpath indexpath:nsindexpath) { (Cell as! Customcell). display =true} func TableView (Tableview:uitableview, Didenddisplayingcell Cell:uitableviewcell, Forrowatindexpath Inde Xpath:nsindexpath) {(Cell as! Customcell). display =false }}
Swift-uitableviewcell Countdown Reuse Solution