0
添加UIProgressView與StoryBoard,並將其設置爲ANIHTTPRequet的進度條 我是否啓動UIProgressView或使用函數setDownloadProgressDelegate:是否正確? TIA! TIA!進度條不工作與ASIHTTPRequest
@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];
}
Thanks.The的解決辦法是刪除你的身影out.This似乎初始化兩次行(IB幫助我們INIT一次)。而我試圖移動到另一個庫[UIDownloadBar](。 https://github.com/sakrist/UIDownloadBar)更容易擴展 – Maadiah 2012-07-18 05:50:27