title: UIImageView+AFNetworking Success Block with resize image and return image height to resize cell height
body: <p>I am using UIImageView+AFNetworking to get the image URL and using that Image to resize if the size is big. and if the size is big I need to return the height of the image in the </p>
  
  <pre><code>- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
  </code></pre>
  
  <p>The problem is the height is returned before the block is executed  and resize is returned. I want to wait till the the process which I am carrying out in the success block. to complete and then return the image size in the method.</p>
  
  <pre><code>- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
   UIImageView *ivImage = [[UIImageView alloc]init];
              __block BOOL isResized = NO;
              [ivImage setImageWithURLRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:[[marrMainNewsFeed objectAtIndex:indexPath.row] valueForKey:@"image"]]] placeholderImage:[UIImage imageNamed:@"placeholder.png"] success:^(NSURLRequest *request, NSHTTPURLResponse *response, UIImage *image) {
                  //                cell.ivImage.image = image;
                  NSLog(@"image size %f",image.size.width);
                  if (ivImage.image.size.width &gt;= SCREEN_WIDTH - 10) {
                      // I resize my image by calling following method
                      ivImage.image = [CommonFunctions imageWithImage:ivImage.image scaledToMaxWidth:SCREEN_WIDTH maxHeight:0];
                      ivImage.frame = CGRectMake(ivImage.frame.origin.x, ivImage.frame.origin.y, SCREEN_WIDTH - 4, ivImage.image.size.height);
                      isResized = YES;
                      ivImage.image = image;
  
  //                    height = ivImage.image.size.height;
                  } else {
                      ivImage.image = image;
                      ivImage.contentMode = UIViewContentModeCenter;
  //                    height = ivImage.image.size.height;
                  }
              } failure:^(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error) {
                  NSLog(@"Request failed with error: %@", error);
              }];
              NSLog(@"new Height %@ for index %@",isResized?@"YES":@"NO",indexPath);
                                return height + 350;
  }
  </code></pre>
  
  <p>The return is fired first and then the image is resized and gives the height of the image. I want to wait till the resize is completed and then return the height of the cell.</p>
  
  <p>Hope I would get the fruitful resutls </p>