How to add the “spinning wheel” Activity Indicator to a web view

It’s always good to have something happening while you’re loading a UIWebView. You can use the UIActivityIndicator for this. It’s basically an animated GIF file that you can connect to your code like many other elements. To make it work we need to conform to the UIWebViewDelegate protocol and then query our web view to see if he’s finished loading.

Here’s how we do that:

  • add the protocol to your header file
  • make sure you drag from your Web View to your View Controller’s delegate (control drag to the orange oval in your storyboard, at the bottom of your view controller)
  • add the method webViewDidFinishLoad:(UIWebView *)myWebView
  • in it call the stopAnimating method for your spinning wheel.

In the storyboard make sure that you set the behaviour of the Activity Indicator to “animating” and “hides when stopped”.

Here are my files:

[emember_protected]

You can create the same effect in the status bar of your application. Click here for details.

[/emember_protected]

About Jay Versluis

Jay is a medical miracle known as Super Survivor. He runs two YouTube channels, five websites and several podcast feeds. To see what else he's up to, and to support him on his mission to make the world a better place, check out his Patreon Campaign.

One thought on “How to add the “spinning wheel” Activity Indicator to a web view

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.