AFHTTPRequestOperationManager adds a chrysanthemum, requestmapping

Source: Internet
Author: User

AFHTTPRequestOperationManager adds a chrysanthemum, requestmapping
Q:

Can you help me to understand, how to useUIActivityIndicatorView+AFNetworkingOrUIProgressView+AFNetworking. Do I need to create one moreUIViewControllerAnd if yes, where do I need to implement it? Have found out that I need to usesetProgressWithUploadProgressOfOperationOrsetAnimatingWithStateOfOperation, But I still need an example.

My code is:

AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];manager.responseSerializer = [AFJSONResponseSerializer serializer];[manager.requestSerializer setValue:@"application/json" forHTTPHeaderField:@"Accept"];[manager.requestSerializer setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];[manager.requestSerializer setValue:@"" forHTTPHeaderField:@""];manager.responseSerializer.acceptableContentTypes = [NSSet setWithObject:@"text/html"];[manager GET:@"blablabla" parameters:nil success:^(AFHTTPRequestOperation *operation, id responseObject) {    // 3    //[self.view setAnimatingWithStateOfOperation:operation];    NSLog(@"JSON: %@", responseObject);    NSArray *carsList = responseObject[@"data"];    [self showStream:carsList];} failure:^(AFHTTPRequestOperation *operation, NSError *error) {    // 4    UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Error"                                                        message:[error localizedDescription]                                                       delegate:nil                                              cancelButtonTitle:@"Ok"                                              otherButtonTitles:nil];    [alertView show];}];




A:

I guess, you want to show UIActivityIndicator while operation is loading. So you have to do something like this:

// your codeAFHTTPRequestOperation *operation = [manager GET:@"blablabla" parameters:nil success:^(AFHTTPRequestOperation *operation, id responseObject) {    // even more code} failure:^(AFHTTPRequestOperation *operation, NSError *error) {    // and here}];UIActivityIndicatorView *indicatorView = [[UIActivityIndicatorView alloc] init];indicatorView.frame = /*calculate frame here*/;[self.view addSubView:indicatorView];[indicatorView setAnimatingWithStateOfOperation:operation];




Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.