Cover by Vandad Nahavandipoor

Safari, the world’s most comprehensive technology and business learning platform.

Find the exact information you need to solve a problem on the fly, or go deeper to master the technologies and skills you need to succeed

Start Free Trial

No credit card required

O'Reilly logo

2.23. Displaying Progress with UIProgressView

Problem

You want to display a progress bar on the screen, depicting the progress of a certain task, for instance, the progress of downloading a file from a URL.

Solution

Instantiate a view of type UIProgressView and place it on another view.

Discussion

A progress view is what programmers generally call a progress bar. An example of a progress view is depicted in Figure 2-74.

A simple progress view

Figure 2-74. A simple progress view

Progress views are generally displayed to users to show them the progress of a task that has a well-defined starting and ending point. For instance, downloading 30 files is a well-defined task with a specific starting and ending point. This task obviously finishes when all 30 files have been downloaded. A progress view is an instance of UIProgressView and is initialized using the designated initializer of this class, the initWithProgressViewStyle: method. This method takes in the style of the progress bar to be created as a parameter. This parameter is of type UIProgressViewStyle and can therefore be one of the following values:

UIProgressViewStyleDefault

This is the default style of the progress view. An example of this is the progress view shown in Figure 2-74.

UIProgressViewStyleBar

This is similar to the UIProgressViewStyleDefault but is meant to be used for progress views that are to be added to a toolbar.

An instance of UIProgressView ...

Find the exact information you need to solve a problem on the fly, or go deeper to master the technologies and skills you need to succeed

Start Free Trial

No credit card required