Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[AFNetworking] Overlay doesn't disappear or show the final state of the operation #57

Closed
85636682 opened this issue Aug 18, 2014 · 7 comments

Comments

@85636682
Copy link

i use MRProgressOverlayView+AFNetworking! but in one tableviewcontroller, it always loading,can not stop! how can i do?!

- (void)viewDidLoad
{
    [super viewDidLoad];
    self.tableView.contentInset = UIEdgeInsetsMake(-1.0f, 0.0f, 0.0f, 0.0);

    AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
    AFHTTPRequestOperation *operation = [manager GET:[[NSString stringWithFormat:@"http://localhost:3000/api/teams/%@", self.team_id] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding] parameters:nil success:^(AFHTTPRequestOperation *operation, id responseObject) {
        self.labelTeamName.text = responseObject[@"name"];
        self.teamSportCell.detailTextLabel.text = responseObject[@"sport"];
        self.teamAreaCell.detailTextLabel.text = responseObject[@"area"];
        self.teamMemberCell.detailTextLabel.text = [NSString stringWithFormat:@"%@个", responseObject[@"members_count"]];
        if ([responseObject[@"avatar"] isEqualToString:@"blank.png!80x80"]) {
            self.imageTeamAvatar.image = [UIImage imageNamed: @"avatar.png"];
        } else {
            NSURLRequest *imageRequest = [NSURLRequest requestWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@", responseObject[@"avatar"]]]];
            [self.imageTeamAvatar setImageWithURLRequest:imageRequest placeholderImage:nil success:^(NSURLRequest *request, NSHTTPURLResponse *response, UIImage *image) {
                self.imageTeamAvatar.image = image;
            } failure:^(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error) {
                self.imageTeamAvatar.image = [UIImage imageNamed: @"avatar.png"];
            }];
        }
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"异常提示" message:@"网络异常" delegate:self cancelButtonTitle:@"确定" otherButtonTitles: nil];
        [alert show];
    }];

    MRProgressOverlayView *overlayView = [MRProgressOverlayView showOverlayAddedTo:self.view animated:YES];
    [overlayView setModeAndProgressWithStateOfOperation:operation];
    [overlayView setStopBlockForOperation:operation];

    [self.tableView addHeaderWithTarget:self action:@selector(headerRereshing)];
}
@mrackwitz
Copy link
Owner

What exactly is the problem:

  1. Does the progress overlay fail to show the finish state of the operation and doesn't disappear by itself?
  2. Are you not able to stop the operation, while it is in progress, by pressing the stop button?

@85636682
Copy link
Author

@mrackwitz the problem like one!
the progress overlay always loading and can not show the success or fail in first time !
if i popped view and push the controller again, progress overlay worked!

@85636682
Copy link
Author

@mrackwitz
qq20140818-2

@mrackwitz
Copy link
Owner

This seems like the operation is already finished, before it was observed by the progress overlay view. Can you check if this is the case?

@mrackwitz mrackwitz changed the title i use MRProgressOverlayView+AFNetworking! but in one tableviewcontroller, it always loading,can not stop! how can i do?! [AFNetworking] Overlay doesn't disappear or show the final state of the operation Aug 18, 2014
@85636682
Copy link
Author

@mrackwitz
Copy link
Owner

I think the best solution will be a new release, which changes the behavior slightly.
Probably it would behave more as expected, if the progress view will be hidden, when the operation is finished.

@mrackwitz
Copy link
Owner

@85636682: You may want to try this branch. Does this fix your issue?

mrackwitz added a commit that referenced this issue Aug 20, 2014
…ration_finished

Fixes #57: Hides overlay if task/operation is finished
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants