2014-02-11 44 views
1

我在將UIImageView上的setImageWithURL轉換爲UITableViewCell時遇到問題。
這是呈現的表視圖。在此之前,我按下了UITableViewCell,然後在右側按下它。AFNetworking setImageWithURL:placeholderImage:錯誤的大小

UITableView before press UITableView after press

這裏是我的tableView:的cellForRowAtIndexPath方法:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { 
    static NSString *CellIdentifier = @"AddFriendCell"; 
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath]; 

    NSDictionary *user = self.result[indexPath.row]; 
    cell.textLabel.text = [NSString stringWithFormat:@"%@ %@", user[@"firstname"], user[@"lastname"]]; 
    if (user[@"picture"]) { 
     NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"http://jawbone.com/%@", user[@"picture"]]]; 
     [cell.imageView setImageWithURL:url placeholderImage:cell.imageView.image]; 
    } 

    return cell; 
} 

回答

1

我只是有一個非常類似的問題昨晚。發生這種情況是因爲UITableViewCell覆蓋了imageview屬性上的約束,並且出於某種原因有一些不可靠的功能。我知道這並不是最清楚的解釋,因爲我最終沒有找到問題的確切來源,但是我找到了解決方法。

我此修復程序是:

  1. 創建一個自定義的UITableViewCell
  2. 添加一個UIImageView(調用比ImageView的其他財產的東西)和標題的UILabel
  3. 約束/設置了的UIImageView的框架