奇妙な問題が発生しています。データを解析して画像の URL を取得し、それをセルの ' imageView
' に設定しています。私が理解できることから、「 」のサイズをcornerRadius
画像の高さの半分に設定する必要があります。高さ 100 のテーブル ビュー セルにデータを取り込むため、角の半径を 50 に設定しています。
しかし、画像の最初の初期読み込みでビューが読み込まれると、小さなひし形として表示されます。デバイスを回転すると (テーブル ビューも回転します)、丸みのあるフルサイズの画像が自動的に表示されます。
これは、初期ロードの例の画像です。
なぜこれが起こるのか誰か知っていますか?
これが私のtableViewコードです
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
NSDictionary *generatedUsers = [self.randomlyGeneratedUsersArray objectAtIndex:indexPath.row];
NSURL *url = [NSURL URLWithString:[generatedUsers valueForKeyPath:@"user.picture"]];
cell.textLabel.text = [NSString stringWithFormat:@"%@ %@", [generatedUsers valueForKeyPath:@"user.name.first"], [generatedUsers valueForKeyPath:@"user.name.last"]];
cell.detailTextLabel.text = [generatedUsers valueForKeyPath:@"user.location.street"];
[cell.imageView setImageWithURL:url placeholderImage:[UIImage imageNamed:@"placeholder"]];
cell.imageView.layer.cornerRadius = 50.0f;
cell.imageView.layer.masksToBounds = YES;
return cell;
}