First, Case introduction: Click the button upload, the activity indicator rotation, click again to stop the rotation; Click the download button progress bar loading full after the prompt, 01, figure 02.
Fig. 01 FIG. 02
Second, the case steps:
1, choose Simple View aplication, named cq.31. Activity indicator and progress bar, 03.
Figure 03
2, main.storyboard,04, figure 05.
Fig. 04 Fig. 05
3, CQ31ViewController.h
#import <UIKit/UIKit.h>@interface cq31viewcontroller:uiviewcontroller{ * * * * *myprogressview; -(Ibaction) Starttomove: (ID) sender; -(Ibaction) DownloadProgress: (ID) sender; @end
4, CQ31VIEWCONTROLLER.M
#import "CQ31ViewController.h"@interfaceCq31viewcontroller ()@end@implementationCq31viewcontroller@synthesizeMyTimer;- (void) viewdidload{[Super Viewdidload]; //additional setup after loading the view, typically from a nib.}- (void) didreceivememorywarning{[Super didreceivememorywarning]; //Dispose of any resources the can be recreated.}-(Ibaction) Starttomove: (ID) sender{if([Self.myactivityindicatorview isanimating]) {[Self.myactivityindicatorview stopanimating]; }Else{[Self.myactivityindicatorview startanimating]; }}-(Ibaction) DownloadProgress: (ID) sender{MyTimer= [Nstimer scheduledtimerwithtimeinterval:1.0target:self selector: @selector (download) Userinfo:nil Repeats:yes];}- (void) download{self.myProgressView.progress=self.myprogressview.progress+0.1; if(self.myprogressview.progress==1.0) {[MyTimer invalidate]; Uialertview*alert=[[uialertview Alloc]initwithtitle:@"Download completed! "message:@"" Delegate: nil Cancelbuttontitle:@"OK"Otherbuttontitles:nil]; [Alert show]; }}@end