我使用URL中的图像创建表视图,但图像不会重新调整大小以适合所有视图,除非我在该行中预先设置了大小。 任何想法为什么发生这种情况? 这是一个自定义的tableviewTableView中的图像大小不正确
我的代码是:
- (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,但它仍然没有工作。
谢谢。
发布一些代码..... – 2011-05-30 16:25:25
显示代码,您从URL检索图像,并将其设置在图像视图。 – rptwsthi 2011-05-31 06:31:15