permalink

3

Add UIActivityIndicatorView to UINavigationBar

For me it took sometime to figure out how to show activity indicator in the navigation bar. Later I found it was very simple. When you push a view to the navigation you get to play with navigationItem property on the view that is being pushed. In your viewWillAppear method you can add this code.

I have done a sample application demonstrating this code. It is based on iPhone navigation project template. In the application I have two action to start and stop the animation.

Screen shot of the application

Activity indicator on navigation bar

Download Load Activity Indicator Xcode project files.

3 Comments

  1. How would I START the animation before I “visit the web to get some data” and then STOP the animation after the data is received?

    “Demo code is great”… but “real world use examples” are even better.

    (There aren’t too many people that just need 2 buttons to manually start/stop the animation.)