【发布时间】:2015-02-25 07:42:00
【问题描述】:
问题
我正在开发一个应用程序,我从上传到网站的 JSON 文件下载数据。下载的所有内容都正确显示...但是我有这个大小为 54x54 的 UIImageView ,每当我尝试从 JSON 文件下载图像时,它都会显示其原始大小而不是图像视图的大小。
这对于视网膜设备来说是个问题,因为图像必须与图像视图的大小相同。
如何使图像在正确的测量值处调整大小?
http://i.stack.imgur.com/qOQz5.png
这是我所拥有的:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
UILabel *label;
label = (UILabel *)[cell viewWithTag:1];
label.text = [arrayTitle objectAtIndex:indexPath.row];
label.frame = CGRectMake(70, 8, 209, 21);
label = (UILabel *)[cell viewWithTag:2];
label.text = [arraySubtitle objectAtIndex:indexPath.row];
label.frame = CGRectMake(70, 29, 209, 33);
label.numberOfLines = 2;
UIImageView *imgView = (UIImageView *)[cell viewWithTag:0];
imgView.image = [UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@", [arrayImage objectAtIndex:indexPath.row]]]]];
imgView.frame = CGRectMake(8, 8, 54, 54);
cell.imageView.image = imgView.image;
return cell;
}
【问题讨论】:
标签: ios json xcode image uiimageview