title: UIImageView has weird space to the left of the image in a tableview
body: <p>I have a <code>UITableView</code> that I programatically add to my view. I then load the data from an API, and resize the images to fit it to the width of the current device, and accordingly adjust the height of the image to keep the aspect ration, I then use that height as the height of the cells for my table view.</p>
  
  <p>Here is some code and a screenshot of the result:</p>
  
  <p>This is the image resize code:</p>
  
  <pre><code>+ (UIImage*)imageWithImage:(UIImage *)image convertToWidth:(float)width {
      float ratio = image.size.width / width;
      float height = image.size.height / ratio;
      CGSize size = CGSizeMake(width, height);
      UIGraphicsBeginImageContext(size);
      [image drawInRect:CGRectMake(0, 0, size.width, size.height)];
      UIImage * newimage = UIGraphicsGetImageFromCurrentImageContext();
      UIGraphicsEndImageContext();
      return newimage;
  }
  </code></pre>
  
  <p>This is in the init method of my custom table view cell:</p>
  
  <pre><code> _imgPicture = [[UIImageView alloc] init];
   _imgPicture.contentMode = UIViewContentModeScaleAspectFit;
   [self.contentView addSubview:_imgPicture];
  </code></pre>
  
  <p>This is my <code>cellForRowAtIndexPath</code></p>
  
  <pre><code>RecipeTableViewCell* cell = [tableView dequeueReusableCellWithIdentifier:@"recipe_cell"];
  
  if(cell == nil)
  {
      cell = [[RecipeTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"recipe_cell"];
  }
  NSDictionary *dict = [recipeArray objectAtIndex:[indexPath row]];
  cell.lblName.text = [dict valueForKey:@"name"];
  
  if([@"data:image/jpg;base64,null" isEqualToString:[NSString stringWithFormat:@"%@,%@",[dict valueForKey:@"pictureType"], [dict valueForKey:@"picture"]]])
  {
      cell.imgPicture.image = defaultImage;
  }
  else
  {
      NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"%@,%@",[dict valueForKey:@"pictureType"], [dict valueForKey:@"picture"]]];
      NSData *imageData = [NSData dataWithContentsOfURL:url];
      UIImage *ret = [UIImage imageWithData:imageData];
      CGRect screenRect = [[UIScreen mainScreen] bounds];
      CGFloat screenWidth = screenRect.size.width;
      cell.imageView.image = [ImageExtension imageWithImage:ret convertToWidth:screenWidth];
  }
  
  return cell;
  </code></pre>
  
  <p><img src="https://i.stack.imgur.com/pNvxP.jpg" alt="Screen shot of the resulting view"></p>
  
  <p>I have tried forcing the <code>UIImageView</code> to be at origin 0, 0 by settings the frame, but that didn't help, I am now thinking that it might be the fact that the image gets resized, and then something in the <code>UITableViewCell</code> breaks, but have no idea what it could be. Some assistance with this will be much appreciated.</p>
  
  <p>Also note I had all this as a storyboard, and it had the exact same result, then I thought let me attempt it programatically and getting the same results.</p>