Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

iOS

Stone Preston
Stone Preston
42,016 Points

implementing a loading view while getting tableView data

Does anyone know how you would go about implementing a loading view (spinning circle type thing) while the tableView is being populated with data?

2 Answers

Rashii Henry
Rashii Henry
16,433 Points

You can use that suggestion or either:

create a new property of UIRefreshControl in your header file.

switch to your implementation then alloc and initialize the property you created. self.refreshControl = [UIRefreshControl alloc] init]; //this will automatically create the spinning circle. so if you run the program it will work but continue to spin.

make sure after you allocate and initialize the UIRefreshControl you use: [self.refreshControl addTarget:self action:@selector(whateverActionYouWillUse) forControlEvent:UIControlEventValueChanged];

then to get the circle to disappear whenever you finish retrieving something you can do something like: if ([self.resfreshControl isRefreshing]) {self.refreshControl endRefreshing};

just a suggestion.

Stone Preston
Stone Preston
42,016 Points

thanks for the suggestion. I actually followed this tutorial to make a more customizable loading indicator.

Rashii Henry
Rashii Henry
16,433 Points

I appreciate it.

I've actually been looking for one so i'll take a look at it now.

You can imitate pull-to-refresh by

[self.refreshControl beginRefreshing];
self.tableView.contentOffset = CGPointMake(0,-100);

Then when you are done:

[self.refreshControl endRefreshing];
self.tableView.contentOffset = CGPointMake(0,0);
Stone Preston
Stone Preston
42,016 Points

awesome ill try this out