IOS Development Study Notes-(3) progress bar, waiting for the animation to stop

Source: Internet
Author: User

IOS Development Study Notes-(3) progress bar, waiting for the animation to stop

1. Create a spatial view, for example:

 

2. Compile the corresponding. h Code as follows:

 

#import 
 
  @interface ViewController : UIViewController@property (weak, nonatomic) IBOutlet UIActivityIndicatorView *activWaitNetWork;@property (weak, nonatomic) IBOutlet UIProgressView *pgrsDownLoad;@property (weak,nonatomic) NSTimer *timer;- (IBAction)onclickStartRequest:(id)sender;- (IBAction)onclickDownLoad:(id)sender;@end
 


 

3. Compile the implementation of the corresponding. m file. The notes are more detailed:

 

 

# Import ViewController. h @ interface ViewController () @ end @ implementation ViewController @ synthesize activWaitNetWork; @ synthesize pgrsDownLoad; @ synthesize timer;-(void) viewDidLoad {[super viewDidLoad]; // Do any additional setup after loading the view, typically from a nib .} -(IBAction) onclickStartRequest :( id) sender {// if it is running, stop; otherwise, start to load if ([activWaitNetWork isAnimating]) {[activWaitNetWork stopAnimating];} else {[activWaitNetWork startAnimating] ;}}-(IBAction) onclickDownLoad :( id) sender {// start the progress pgrsDownLoad again. progress = 0; // The progress of the scheduled task and the new Progerss timer = [NSTimer scheduledTimerWithTimeInterval: 1.0 target: self selector: @ selector (update) userInfo: nil repeats: YES];} -(void) update {pgrsDownLoad. progress = pgrsDownLoad. SS + 0.1; // when the progress is complete, the system prompts if (pgrsDownLoad. progress = 1) {[timer invalidate]; UIAlertView * alert = [[UIAlertView alloc] initWithTitle: @ tip message: @ delegate: self cancelButtonTitle: @ confirm otherButtonTitles: @ cancel, nil]; [alert show] ;}}-(void) didReceiveMemoryWarning {[super didreceivemorywarning]; // Dispose of any resources that can be recreated .} @ end

Iv. Running effect:

 

 

 

Related Article

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.