下面是代码:的UIImageView定制没有显示出来的UITableViewCell
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"ConvoreCell";
ConvoreCell * cell = (ConvoreCell *) [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
NSArray *topLevelObjects = [[NSBundle mainBundle] loadNibNamed:@"ConvoreCell" owner:nil options:nil];
for (id currentObject in topLevelObjects){
if ([currentObject isKindOfClass:[UITableViewCell class]]){
cell = (ConvoreCell *) currentObject;
break;
}
}
}
NSMutableDictionary *cellValue = [results objectAtIndex:indexPath.row];
NSString *picURL = [[cellValue objectForKey:@"creator"] objectForKey:@"img"];
if ([picURL isEqualToString:@"https://secure.gravatar.com/avatar/1f043010eb1652b3fab3678167dc0487/?default=https%3A%2F%2Fconvore.com%2Fmedia%2Fimages%2Feric.png&s=80"])
picURL = @"https://convore.com/media/images/eric.png";
if ((picURL != (NSString *) [NSNull null]) && (picURL.length !=0)) {
NSLog(@"%@", picURL);
NSData *imgData = [[[NSData dataWithContentsOfURL:
[NSURL URLWithString:
picURL]] autorelease] retain];
[cell.pic initWithImage:[[UIImage alloc] initWithData:imgData]];
} else {
cell.pic = nil;
}
//NSLog(@"Name is : %@", [cellValue objectForKey:@"name"]);
cell.title.text = [cellValue objectForKey:@"name"];
cell.info.text = (@"Created by: %@", [[cellValue objectForKey:@"creator"] objectForKey:@"name"]);
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
// Configure the cell...
return cell;
}
出于某种原因,该图像没有显示出来。我在这里做错了什么?图片的网址是有效的,我查了一下。
我也不想对TableViewCell附属视图,我没有指定因为没有在IB,但它仍然显示了...我的附件属性设置为none已经
,你能指点我可以保存图像的资源吗? – aherlambang 2011-02-18 17:32:20