iOS¿ª·¢ÍøÂçƪ¡ªÊ¹ÓÃASI¿ò¼Ü½øÐÐÎļþÏÂÔØ

·¢±íÓÚ£º2015-7-03 09:52

×ÖÌ壺´ó ÖРС | ÉÏһƪ | ÏÂһƪ | ÎÒҪͶ¸å

 ×÷Õߣº¾´ÍùÊÂÒ»±­¾Æ    À´Ô´£º51TestingÈí¼þ²âÊÔÍø²É±à

·ÖÏí£º
¡¡¡¡Èý£¬½áºÏһЩ½ø¶ÈÏÔʾµÄµÚÈý·½¿ò¼ÜʹÓÃ
¡¡¡¡È¥code4appÉÏÃæËæ±ãÏÂÔØÒ»¸öÏÔʾÏÂÔؽø¶ÈµÄµÚÈý·½¿ò¼Ü£¬ÕâÀïÒÔDACircularProgressViewΪÀý×Ó¡£
¡¡¡¡µ¼Èë¸Ã¿ò¼Ü±ØÒªµÄÎļþºó£¬¼òµ¥Ê¹ÓÃÈçÏ¡£
¡¡¡¡´úÂëʾÀý£º
1 #import "YYViewController.h"
2 #import "ASIHTTPRequest.h"
3 #import "DACircularProgressView.h"
4
5 @interface YYViewController ()<ASIProgressDelegate>
6
7 @property (weak, nonatomic) IBOutlet DACircularProgressView *circularView;
8 @property (weak, nonatomic) IBOutlet UIProgressView *progress;
9 @end
10
11 @implementation YYViewController
12
13 - (void)viewDidLoad
14 {
15     [super viewDidLoad];
16
17     //ÉèÖûù±¾µÄһЩÊôÐÔ
18     self.circularView.trackTintColor=[UIColor lightGrayColor];
19     self.circularView.progressTintColor=[UIColor yellowColor];
20 }
21
22 -(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
23 {
24     //ÏÂÔØ·þÎñÆ÷ÉϵÄÎļþ
25     [self download];
26 }
27
28 #pragma mark-ÏÂÔØÎļþ
29 -(void)download
30 {
31     //1.´´½¨ÇëÇó¶ÔÏó
32     NSURL *url=[NSURL URLWithString:@"http://127.0.0.1:8080/MJServer/resources/video.zip"];
33     ASIHTTPRequest *request=[ASIHTTPRequest requestWithURL:url];
34
35     //2.ÉèÖÃÏÂÔØÎļþ±£´æµÄ·¾¶
36     NSString *cachepath=[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES)lastObject];
37     NSString *filename=[cachepath stringByAppendingPathComponent:@"video.zip"];
38     request.downloadDestinationPath=filename;
39     NSLog(@"%@",filename);
40
41     //3.ÉèÖÃÏÂÔؽø¶ÈµÄ´úÀí
42     request.downloadProgressDelegate=self.circularView;
43
44     //4.·¢ËÍÍøÂçÇëÇó£¨Òì²½£©
45     [request startAsynchronous];
46
47     //5.ÉèÖÃÖ§³Ö¶ÏµãÏÂÔØ
48     request.allowResumeForFileDownloads=YES;
49
50     //5.ÏÂÔØÍê±Ïºó֪ͨ
51     [request setCompletionBlock:^{
52         NSLog(@"ÎļþÒѾ­ÏÂÔØÍê±Ï");
53     }];
54 }
55
56 #pragma mark-¼àÌýÏÂÔؽø¶ÈµÄ´úÀí·½·¨
57 @end
¡¡¡¡ÏÔʾЧ¹û£º
¡¡¡¡ÌرðÌáʾ£º
33/3<123
¼ÛÖµ398ÔªµÄ²âÊԿγÌÃâ·ÑÔùËÍ£¬ÌîÎʾíÁìÈ¡°É£¡

¹Ø×¢51Testing

ÁªÏµÎÒÃÇ

¿ì½ÝÃæ°å Õ¾µãµØͼ ÁªÏµÎÒÃÇ ¹ã¸æ·þÎñ ¹ØÓÚÎÒÃÇ Õ¾³¤Í³¼Æ

·¨ÂɹËÎÊ£ºÉϺ£äîϪÂÉʦÊÂÎñËù ÏîÆåÂÉʦ
°æȨËùÓÐ ÉϺ£²©Îª·åÈí¼þ¼¼Êõ¹É·ÝÓÐÏÞ¹«Ë¾ Copyright©51testing.com 2003-2022
ͶËß¼°Òâ¼û·´À¡£ºwebmaster@51testing.com; ÒµÎñÁªÏµ£ºservice@51testing.com 021-64471599-8017

»¦ICP±¸05003035ºÅ

»¦¹«Íø°²±¸ 31010102002173ºÅ