ios - Refresh TableView Content with UIRefreshControl -


please refresh contents of table not work.

- (void)viewdidload {     [super viewdidload];     self.title = @"last news";     [uiapplication sharedapplication].networkactivityindicatorvisible = yes;     //     nsurl *url = [nsurl urlwithstring:@"http://www.apinae.com/json.php"];     nsurlrequest *request = [nsurlrequest requestwithurl:url];     [[nsurlconnection alloc] initwithrequest:request delegate:self];      // test refresh     uirefreshcontrol *refreshcontrol = [[uirefreshcontrol alloc] init];     refreshcontrol.tintcolor = [uicolormagentacolor];     self.refreshcontrol = refreshcontrol;     // test refresh  } 

thanks in advance.

you didn't set action refresh control. try instead:

-(void) viewdidload {     [super viewdidload];     uirefreshcontrol *refreshcontrol = [uirefreshcontrol new];     [refreshcontrol addtarget:self action:@selector(refresh:) forcontrolevents:uicontroleventvaluechanged];     refreshcontrol.attributedtitle = [[nsattributedstring alloc] initwithstring:@"pull refresh..."];     self.refreshcontrol = refreshcontrol; }  - (void)refresh:(uirefreshcontrol *)sender  {     // ... refresh code     nsurl *url = [nsurl urlwithstring:@"http://www.apinae.com/json.php"];     nsurlrequest *request = [nsurlrequest requestwithurl:url];     [[nsurlconnection alloc] initwithrequest:request delegate:self];      [sender endrefreshing]; } 

well, call -endrefreshing should in delegate method stops refreshing when file downloaded , refreshed in table, idea.


Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

javascript - jQuery .height() return 0 when visible but non-0 when hidden -