2014-11-01 65 views
0

UIImageView工作完美,但它被拉伸其UITableViewCell的UIImageView伸展在iOS 8的故事板自動佈局

之外,我甩開了Instagram的API,這是612x612標準分辨率照片。我需要把它放在UIImageView的自定義UITableViewCell中,它將使用自動佈局來更改每個設備UIImageView的尺寸。

我不確定這是如何在Xcode 6 iOS 8中工作的,因爲我試過的東西到目前爲止還沒有工作,因爲圖像只是在設備視圖的範圍之外伸展。

任何幫助將不勝感激,謝謝!

CustomTableViewCell.m

- (void)layoutSubviews { 
    [super layoutSubviews]; 
     [self.imageViewPic setTranslatesAutoresizingMaskIntoConstraints:YES]; 
} 

ViewController.m

self.tableView.rowHeight = UITableViewAutomaticDimension; 
self.tableView.estimatedRowHeight = 600.0; 

NSString *imageURL = [NSString stringWithFormat:@"%@", standardResolutionLocal.url]; 

    __weak MWebListTableViewCellTwo *mCell = api2Cell; 
    [mCell.imageViewPic 
    sd_setImageWithURL:[NSURL URLWithString:imageURLInstagram] 
    placeholderImage:[UIImage imageNamed:@"placeholder"]]; 

回答

1

基於自動佈局動態小區heught使用時,我注意到的UIImageView問題。視圖佈局良好,但圖像本身並不像「contentMode」屬性所定義的那樣拉伸。

在顯示之前強制顯示單元格的佈局,以某種方式修復它,但在選擇之後它又回到非拉伸版本,因此需要做更多的工作。 UITableView的可能的子類將完成這項工作。

- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
    [cell layoutIfNeeded]; 
} 
+0

真棒,有道理,謝謝! – SRMR 2014-11-27 00:26:03