Force Reload Table View
All,
How would I force reload a table view (within a view controller) every five seconds for fifteen se开发者_运维百科conds when a button is pressed?
Thanks, James
First you create a timer when you press your button,
NSTimer *timer = [NSTimer scheduledTimerWithTimeInterval:5.0 target:self selector:@selector(updateMethod) userInfo:nil repeats:YES];
Then in your method that fires every 5 seconds
- (void) updateMethod
{
[self.tableView reloadData];
}
Check out NSTimers
& Apple Documentation. This will give you a concept about intervals and help you with the delay you are looking for.
And for reloading tableview, [self.tableView reloadData];
should to the trick.
精彩评论