开发者

UIImageView in customCell

开发者 https://www.devze.com 2023-02-25 19:11 出处:网络
I have problem, I have got xib based custom cell and I want to show imageview there. Tried this: UIImageView *flag1;

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

0

精彩评论

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