cs193p – Assignment #5 Task #3

Please note, this blog entry is from a previous course. You might want to check out the current one.

Your primary table view must now have Refreshing enabled (i.e. you can pull down on it to activate the UIRefreshControl). Doing so should refetch the Stanford photo information from Flickr (of course, it’s unlikely to have changed, but refetch anyway).

You could drag out the refresh-control gestures in storyboard (you would have to do it twice) – or create it in code:

- (void)viewDidLoad
{
    [super viewDidLoad];
    self.refreshControl = [[UIRefreshControl alloc] init];
    [self.refreshControl addTarget:self
                            action:@selector(loadPhtosFromFlickr)
                  forControlEvents:UIControlEventValueChanged];
    [self loadPhtosFromFlickr];
}

… and move the download code to a new method:

- (void)loadPhtosFromFlickr
{
    [self.refreshControl beginRefreshing];
    ...
    dispatch_async(queue, ^{
        ...
        dispatch_async(dispatch_get_main_queue(), ^{
            ...
            [self.refreshControl endRefreshing];
        });
    }); 
}

The complete code is available on github.

FacebooktwitterredditpinterestlinkedintumblrmailFacebooktwitterredditpinterestlinkedintumblrmail

Leave a Reply

Your email address will not be published.