UIImageView in customCell
I have problem, I have got xib based custom cell and I want to show imageview there.
Tried this:
UIImageView *flag1;
UIImageView *flag2;
and
@property (nonatomic, retain) IBOutlet UIImageVie开发者_如何学JAVAw *flag1;
@property (nonatomic, retain) IBOutlet UIImageView *flag2;
Connect it in IB
and this:
cell.flag1 = [UIImage imageNamed:[rowData objectForKey:@"Flag1"]];
How to fix it to get it working?
Thanks
You never set an IBOutlet. Only IB sets IBOutlets. So in this case, what you meant to say is:
cell.flag1.image = [UIImage imageNamed:[rowData objectForKey:@"Flag1"]];
You should be receiving warnings in your code, complaining about a type mismatch. Be sure to pay attention to these warnings.
cell.flag1 = [UIImage imageNamed:[rowData objectForKey:@"Flag1"]];
isn't right. You are assigning a UIImage to a UIImageView.
[cell.flag1 setImage:...]
is the right code for this
精彩评论