2016-07-20 5 views
1

beim ersten Laden der Tabellenzelle Bild, wird das Bild „zerquetscht“:SDWebImage Zelle Bildbetrachtungsgröße falsch auf dem ersten Last

enter image description here

Wenn ich die Zurück-Taste getroffen, und dann vorwärts gehen erfrischt und sieht gut aus:

enter image description here

Jede Idee, warum dies geschieht? Hat es etwas mit meiner Platzhalter-Bildgröße zu tun? Ich kann mir einfach nicht vorstellen, was es sein könnte.

-View-Controller:

- (NSURL *)image { 
    NSString *string = [NSString stringWithFormat:@"%@", self.details[@"image"]]; 
    NSURL *url = [NSURL URLWithString:string]; 
    return url; 
} 

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

    // Configure the cell... 
    if (!cell) { 
     cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier]; 

    } 

    switch (indexPath.row) { 
     case 0: 
      cell.textLabel.text = [self name]; 
      cell.detailTextLabel.text = @"Name"; 
      break; 
     case 1: 
      cell.textLabel.text = [self email]; 
      cell.detailTextLabel.text = @"Email"; 
      break; 
     case 2: 
      cell.textLabel.text = [self phone]; 
      cell.detailTextLabel.text = @"Phone"; 
      break; 
     case 3: 
      cell.textLabel.text = @"Img"; 
      break; 
     default: 
      break; 
    } 
    [cell.imageView sd_setImageWithURL:[self image] 
         placeholderImage:[UIImage imageNamed:@"placeholder.png"] 
          completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL) { 
           // ... completion code here ... 
           NSLog(@"Loaded: %@", image); 
          }]; 

    return cell; 
} 

Antwort

2

Versuchen Sie folgendes:

cell.imageView.contentMode = UIViewContentModeScaleAspectFit; 
+0

Wo würden Sie diese setzen? Vielleicht innerhalb oder außerhalb des Completion Blocks oder woanders? – SRMR

+0

Ich denke nach dem Abschlussblock – Hussein

+0

Ah ok klingt gut – SRMR