4

I know that I can use SVProgressHUD any time I need to show user that something is being loaded on the whole screen.

However, is there a conventional way to show an activity indicator or spinner inside UITableView in iOS 7 design guidelines. I think SVProgressHUD is just ugly in iOS 7 and I thought there must be a better solution.

What is the Apple way of doing this?

ahmet alp balkan
  • 42,679
  • 38
  • 138
  • 214

2 Answers2

2

The apple way of doing this is by showing activity indicator on top of table view.

You can check the Native Mail application for the its working.

Mail App

Implementation -

UIRefreshControl *refreshControl = [[UIRefreshControl alloc] init];
[refreshControl addTarget:self action:@selector(handleRefresh:) forControlEvents:UIControlEventValueChanged];
self.refreshControl = refreshControl;

You can start/stop refreshing using these methods.

– beginRefreshing – endRefreshing

San
  • 1,796
  • 13
  • 22
  • To elaborate a little further with this, check out the accepted answer on [this stack overflow question](http://stackoverflow.com/questions/17930730/uirefreshcontrol-on-viewdidload) as it gives a full example. – Gareth Jones Dec 13 '13 at 00:09
0

I thought a while about this one as well and came up with the following solution:

By utilizing the table view's backgroundView property, you can set a dedicated background view which can be styled the way you want it.

  1. Create an UIViewController in the Storyboard and style the view it the way you want. My suggestion: An UIActivityIndicatorView and an UILabel centered both horizontally and vertically.
  2. Set a storyboard ID for the view controller.
  3. In the viewDidLoad method paste the following code which assigns the created view to the table view's background. Make sure you set replace the identifier with whatever you set it to earlier.

    self.tableView.backgroundView = ((UIViewController *)[self.storyboard instantiateViewControllerWithIdentifier:@"yourStoryboardID"]).view;
    self.tableView.backgroundColor = [UIColor whiteColor];
    
  4. Whenever you are ready to hide the loading view, just do the following:

    self.tableView.backgroundView.hidden = YES;
    

I hope this helps.

Chris
  • 1
  • 1
  • From the documentation for tableView.backgroundView: "You must set this property to nil to set the background color of the table view." – mbeaty May 04 '15 at 07:53