我有一个奇怪的问题来了。我正在解析数据并提取图片的网址,然后将其设置为单元格'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