ios - Pull to refresh UITableView without UITableViewController is not working -


i can't seem find working solution. i've tried other available solutions implement pull refresh in uitableview without uitableviewcontroller nothing happens.

this relevant code:

@iboutlet weak var tableview: uitableview! var peoplerefreshcontrol:uirefreshcontrol!  override func viewdidload() {     super.viewdidload()      // additional setup after loading view.      peoplerefreshcontrol = uirefreshcontrol()     peoplerefreshcontrol.attributedtitle = nsattributedstring(string: "pull refresh")     peoplerefreshcontrol.addtarget(self, action: "refresh", forcontrolevents: .valuechanged)     // tried     // peoplerefreshcontrol.addtarget(self, action: selector("refresh"), forcontrolevents: .valuechanged)     tableview.addsubview(peoplerefreshcontrol)  }  func refresh(){     println("what!") } 

i can see circle spinning , text "pull refresh" when pull down, function "refresh" never called. doing wrong? there else should doing? i'm not doing special tableview other hiding when it's not being used. somehow problem?

edit: updated code include ":" follows there absolutely no change. still see circle spinning , text "pull refresh" text "what!" never printed out.

override func viewdidload() {     super.viewdidload()      ...     peoplerefreshcontrol.addtarget(self, action: "refresh:", forcontrolevents: .valuechanged)     ... }  func refresh(sender:uirefreshcontrol){     println("what!") } 

is there else should doing?

thats because did not add ":" after word refresh in viewdidload. without it, refresh function won't run. try using code...

var refreshcontrol:uirefreshcontrol!    override func viewdidload()     {         super.viewdidload()          self.refreshcontrol = uirefreshcontrol()         self.refreshcontrol.attributedtitle = nsattributedstring(string: "pull refresh")  //look @ : after "refresh"          self.refreshcontrol.addtarget(self, action: "refresh:", forcontrolevents: uicontrolevents.valuechanged)           self.tableview.addsubview(refreshcontrol)     } 

Comments

Popular posts from this blog

PHP DOM loadHTML() method unusual warning -

python - How to create jsonb index using GIN on SQLAlchemy? -

c# - TransactionScope not rolling back although no complete() is called -