开发者

Puzzling UIImageView behavior in a UITableViewCell

开发者 https://www.devze.com 2023-03-30 14:01 出处:网络
I\'m currently setting the UIImageView in my UITableViewCell like this: // in cellForRowAtIndexPath method

I'm currently setting the UIImageView in my UITableViewCell like this:

// in cellForRowAtIndexPath method
[cell.imageView initWithImage:[UIImage imageNamed:@"myImage.png"]];

However the imageView property on开发者_如何学编程 UITableViewCell is readonly. The code above works but I don't understand why. Any ideas?


Don't ever call -init... unless you're creating an object yourself. The cell creates its own image view (that's why it's read-only); you can simply set the image with cell.imageView.image = [UIImage...];.

0

精彩评论

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