添加带有 StoryBoard 的 UIProgressView,并将其设置为 ANIHTTPRequet 的进度条 我是否正确初始化 UIProgressView 或使用函数 setDownloadProgressDelegate:?蒂亚!
@interface xyzViewController : UIViewController {
ASINetworkQueue *networkQueue;
BOOL failed;
ASIHTTPRequest *request;
NSOperationQueue *queue;
}
@property (strong, nonatomic) IBOutlet UIProgressView *progressBar;
//
- (void)viewDidLoad
{
[super viewDidLoad];
progressBar = [[UIProgressView alloc]initWithProgressViewStyle:UIProgressViewStyleBar];
[progressBar setProgress:0.0 animated:YES];
}
//
-(IBAction) downloadStart{
if (!networkQueue) {
networkQueue = [[ASINetworkQueue alloc] init];
}
failed = NO;
[networkQueue reset];
[networkQueue setRequestDidFinishSelector:@selector(imageFetchComplete:)];
[networkQueue setRequestDidFailSelector:@selector(imageFetchFailed:)];
[networkQueue setShowAccurateProgress: YES];
[networkQueue setDelegate:self];
request = [ASIHTTPRequest requestWithURL:[NSURL URLWithString:@"http://allseeing-i.com/ASIHTTPRequest/tests/images/large-image.jpg"]];
[request setDownloadDestinationPath:[[NSHomeDirectory() stringByAppendingPathComponent:@"Documents"] stringByAppendingPathComponent:@"1.png"]];
[request setDownloadProgressDelegate:progressBar];
[request setUserInfo:[NSDictionary dictionaryWithObject:@"request1" forKey:@"name"]];
[networkQueue addOperation:request];
[networkQueue go];
}