【发布时间】:2011-09-04 22:26:01
【问题描述】:
我正在使用来自 URL 的图像创建一个表格视图,但是在我将其按在行中之前,图像不会重新调整到所有视图的大小。 知道为什么会这样吗? 这是一个自定义的 tableview
我的代码是:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
static NSString *CellIdentifier = @"Celula_Noticias";
Celula_Noticias *cell = (Celula_Noticias*)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
NSArray * top= [[NSBundle mainBundle] loadNibNamed:@"Celula_Noticias" owner:self options:nil];
for(id currentObject in top){
if ([currentObject isKindOfClass:[Celula_Noticias class]]) {
cell= (Celula_Noticias *) currentObject;
break;
}
}
}
cell.Image_Noticias_1.image=[UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:[[noticias objectAtIndex:indexPath.row ] objectAtIndex:0]]]];
cell.Image_Noticias_2.image=[UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:[[noticias objectAtIndex:indexPath.row ] objectAtIndex:2]]]];
cell.Titulo_Noticias_1.text=[[noticias objectAtIndex:indexPath.row ] objectAtIndex:1];
cell.Titulo_Noticias_2.text=[[noticias objectAtIndex:indexPath.row ] objectAtIndex:3];
return cell;
}
表格已正确填充,但图像的开头尺寸不正确。
我尝试过使用 CGRectMake,但还是不行。
谢谢。
【问题讨论】:
-
显示您从 url 检索图像的代码,并将其设置在图像视图上。
标签: iphone ios uitableview uiimageview uiimage