使用StoryBoard添加UIProgressView,并将其设置为ANIHTTPRequet的进度条 我是否正确启动UIProgressView或使用函数setDownloadProgressDelegate: TIA!
@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];
}
答案 0 :(得分:1)
progressBar = [[UIProgressView alloc]initWithProgressViewStyle:UIProgressViewStyleBar];
...并在IB中配置栏外观
@synthesize progressBar;
PS。
Please note that I am no longer working on this library - you may want to consider using something else for new projects. :)