i am trying to communicate to web-service and to retrieve data, while doing that, i try to make progress indication with UIProgressView so that the user know what's going on, however, when i run, i don't see the progress on the UIProgressView. here is my relevant code :
- (void)viewDidLoad {
[super viewDidLoad];
//start request
NSURL *url=[NSURL URLWithString:@"http://iphone01.mtdgroup/admin_V01/stationsProcessing/pickers_management.php"];
ASIFormDataRequest *request=[ASIFormDataReques开发者_StackOverflowt requestWithURL:url];
[request setDelegate:self];
[request setUploadProgressDelegate:loadingProgress];
[request startAsynchronous];
NSLog(@"value: %f",[loadingProgress progress]);
}
the log shows : value: 0.000000
.
According to the ASIHTTPRequest documentation, setting the UIProgressView
as the delegate of the uploadProgressDelegate
is sufficient and ASIHTTPRequest will take care of updating the UIProgressView for me.
am i missing something ? thx for advance :)
You're doing an Asynchronous request so the NSLog executes immediately after the request is started at which point the progress would actually be zero - startAsynchronous actually uses an NSOperationQueue behind the scenes so you'll need to code your own delegate if you want to NSLog the progress:
just include something like this in your view controller:
- (void)setProgress:(float)newProgress {
[loadingProgress setProgress:newProgress];
NSLog(@"value: %f",[loadingProgress progress]);
}
and set:
[request setUploadProgressDelegate:self];
Make sure your class also conforms to the ASIProgressDelegate
protocol.
@interface YourClass : ... <ASIHTTPRequestDelegate,ASIProgressDelegate>
精彩评论