开发者

UIImage doesn't display in UITableView

开发者 https://www.devze.com 2023-04-10 03:20 出处:网络
I have an UIImageView in my UITableViewCell which is not being displayed. I get the image from the addressbook and save it as NSData but it seems that\'s not working.

I have an UIImageView in my UITableViewCell which is not being displayed. I get the image from the addressbook and save it as NSData but it seems that's not working.

I have a method getting the image:

if (A开发者_运维问答BPersonHasImageData(contactrec)){
        CFDataRef imageData = ABPersonCopyImageData(contactrec);
        [person setPic:(NSData *)imageData];
        CFRelease(imageData);
    }

My tableviewcell has the following method who's cellPic is linked to an UIImageView

-(void)setCellPic:(UIImage *) pic{
    cellPic.image = pic;
}

And finally, I have a contactsArray full of persons and for each row, I do:

Person *persona =[contactsArray objectAtIndex:indexPath.row];
UIImage *contactImage = [UIImage imageWithData:(NSData *)[persona pic]];
[cell setCellPic:contactImage];

When I debug the code, it seems like persona has for a contact whith pic 2000bytes but I think it's not doing well converting the NSData to UIImage. At least, when I debug the settle setCellPic, it says that cellPic.image is 0x0

Thanks for your help!


Solved! The problem was with the method setCellPic in the tableviewcell. As the UIImageView had the same cellPic name, the compiler thought I was calling the setter of the cellPic but cellPic wasn't a UIImage, it's UIImageView. So I've changed the method's name and it works fine now! Thanks anyway!

0

精彩评论

暂无评论...
验证码 换一张
取 消