title: Can I set my autolayout constraints so that an imageview is set to the height of the image
body: <p>I am building out a dynamic tableview cell.  The height is dynamic based on the content that is loaded.  I'm running into a hangup with height of the imageview.  The images currently load aspect fill in an imageview that is 100% of the width.  Is it possible to set an autolayout constraint on my imageview so that the imageview is hidden (has a height of 0) if there is no image for a tableview cell?</p>
  
  <p><a href="https://i.stack.imgur.com/UX2t3.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/UX2t3.png" alt="enter image description here"></a></p>
  
  <pre><code>- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
      TableViewTileCell *cell = [tableView dequeueReusableCellWithIdentifier:@"tileCell"];
  
      if (!cell)
      {
          [tableView registerNib:[UINib nibWithNibName:@"TableViewTileCell" bundle:nil] forCellReuseIdentifier:@"tileCell"];
          cell = [tableView dequeueReusableCellWithIdentifier:@"tileCell"];
      }
      cell.tileView.layer.borderColor = [UIColor blackColor].CGColor;
      cell.tileView.layer.borderWidth = 1.0f;
  
      [cell.contentView setBackgroundColor:[UIColor colorWithRed:0.96 green:0.96 blue:0.96 alpha:1.0]];
  
      NSString *url=[self.resultsArray[indexPath.row] valueForKey:@"imageURL"];
  
      cell.tileTitle.text = [self.resultsArray[indexPath.row] valueForKey:@"title"];
      cell.tileDate.text = [self.resultsArray[indexPath.row] valueForKey:@"date"];
      cell.tileContent.text = [self.resultsArray[indexPath.row] valueForKey:@"summary"];
  
      if(![url isEqualToString:@""]){ //If we got a url value back load the image
          [cell.tileImageview setImageWithURL:[NSURL URLWithString:url] placeholderImage:[UIImage imageNamed:@"placeholder.png"]];
      }
  
      return cell;
  }
  </code></pre>