by
978 15
0
5
196k
0
Top 1% !
Popular
Pearl of Wisdom
Specified
OpenSource
Popularity: 8389th place
Created
Modified Oct 22, 2014

Published on:

No tags for this snippet yet.
LanguageText
LicenseMIT_X11

IOS reload data with last update data/time

how to update the last update date/time and hide the refresh control when the data is loaded in the table.
Copy Embed Code
<iframe id="embedFrame" style="width:600px; height:300px;"
src="https://www.snip2code.com/Embed/204253/IOS-reload-data-with-last-update-data-ti?startLine=0"></iframe>
Click on the embed code to copy it into your clipboard Width Height
Leave empty to retrieve all the content Start End
- (void)reloadData { // Reload table data [self.tableView reloadData]; // End the refreshing if (self.refreshControl) { NSDateFormatter *formatter = [[NSDateFormatter alloc] init]; [formatter setDateFormat:@"MMM d, h:mm a"]; NSString *title = [NSString stringWithFormat:@"Last update: %@", [formatter stringFromDate:[NSDate date]]]; NSDictionary *attrsDictionary = [NSDictionary dictionaryWithObject:[UIColor whiteColor] forKey:NSForegroundColorAttributeName]; NSAttributedString *attributedTitle = [[NSAttributedString alloc] initWithString:title attributes:attrsDictionary]; self.refreshControl.attributedTitle = attributedTitle; [self.refreshControl endRefreshing]; } }
If you want to be updated about similar snippets, Sign in and follow our Channels

blog comments powered by Disqus