Uiactivityindicatorview, Uiprogressview activity and progress indicator-ios development

Source: Internet
Author: User

The activity Indicator (Uiactivityindicatorview) informs the user that an operation is in progress. The progress indicator (Uiprogressview) also has the same function, and also tells the user how far away the operation ends.

Both of these indicators are derived from UIView, so they are views or can be attached to a view.

First, Uiactivityindicatorview activity indicator

1. Create

    1. uiactivityindicatorview* Activityindicatorview = [[Uiactivityindicatorview alloc]
    2. Initwithframe:cgrectmake (250.0,20.0,30.0,30.0)];

2. Property settings

Style:

    1. Activityindicatorview.activityindicatorviewstyle= Uiactivityindicatorviewstylegray;

The system offers you 3 different styles:

    1. Uiactivityindicatorviewstylewhitelarge Large White Indicator
    1. Uiactivityindicatorviewstylewhite Standard size White indicator
    1. Uiactivityindicatorviewstylegray Gray indicator for white background

    1. Auto Hide

If you want the indicator to be automatically hidden after it stops, set the Hideswhenstoped property to Yes. The default is yes. The indicator will still appear after set to No stop.

    1. activityindicatorview.hideswhenstoped = NO;

3. Display

You can attach it to any view, such as a table cell, or a view:

    1. [Self.view Addsubview:activityindicatorview];

4. Start and stop

    1. [Activityindicatorview startanimating]; //Start
    2. [Activityindicatorview stopanimating]; //Stop

Second, Uiprogressview progress indicator

Uiprogressview is similar to Uiactivityindicatorview, except that it provides an interface that allows you to display something like a progress bar, so that the user can know how much of the current operation is done.

1. Create

    1. uiprogressview* Progressview = [[Uiprogressview alloc]
    2. Initwithframe:cgrectmake (150.0,20.0,130.0,30.0)];

2. Property settings

Style:

    1. Progressview. Uiprogressviewstyle= Uiprogressviewstyledefault;

The system offers you 2 different styles:

    1. Uiprogressviewstyledefault Standard progress bar
    1. Uiprogressviewstyledefault Dark gray progress bar, for use in toolbars

3. Display

    1. [Self.toolbar Addsubview:progressview];

4. Progress

    1. When it appears that your program can update its progress, the property Progre is a floating-point number between 0.0 to 1.0 :
    1. Progressview.progress = 0. 5;

Third, the network activity indicator

    1. When your application uses the network, a network indicator should be placed on the iphone's status bar to warn users that they are using the network. At this point you can use a property named Networkactivityindicatorvisible for UIApplication. By setting this, you can enable or disable the network indicator: uiapplication* app = [UIApplication sharedapplication];
    2. pp.networkactivityindicatorvisible = YES;

Iv. expansion

Do you think you've learned something new? Do. But I have a better thing. Recommended: Mbprogresshud Https://github.com/jdg/MBProgressHUD A more NB third-party progress indicator, you can follow the example it provides to use it, very powerful.  But one thing I'd like to remind you is that it's asynchronous, so it doesn't block your current program, and if you want to block your program, make a little bit of change in the logic control. Transferred from: http://blog.csdn.net/iukey/article/details/7308311

Uiactivityindicatorview, Uiprogressview activity and progress indicator-ios development

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.