我有一個奇怪的問題來了。我正在解析數據並提取圖片的網址,然後將其設置爲單元格'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;
}
它是正確的,當你的身高是100 – Amitabha