2016-07-20 8 views
1

テーブルセルの画像の最初のロードで、画像は「踏み付け」されていますSDWebImage細胞画像の表示サイズ間違った最初のロードに

enter image description here

私はバックボタンを押した場合は、その後、それがリフレッシュする前に進みますそして、罰金になります。

enter image description here

なぜこれが起こっているすべてのアイデア?それは私のプレースホルダーの画像サイズや何かと何か関係がありますか?私はそれができることを考えることができません。

ビューコントローラ:

- (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; 
} 

答えて

2

これを試してみてください:

cell.imageView.contentMode = UIViewContentModeScaleAspectFit; 
+0

あなたはこれをどこに置くのでしょうか?完了ブロックの内側または外側のように、または他の場所? – SRMR

+0

完了ブロックの後にあると思います – Hussein

+0

ああよく聞こえます – SRMR

関連する問題