In my - (void)setObject:(id)object
method, sometimes I am adding a 0..10 UIImageView dynamically to the cell depending on the object. Now the issue is how do I remove these开发者_开发知识库 UIImageView from the cell in my prepareForReuse?
I have tried doing it via a stupid way, which is to tag each UIImageView from -1 to -10, then in my prepareForReuse I check if it exists, if it does I remove it and then check for the next one. Is there any easier method than this?
You should make each cell contain spots for every imageview you want to display in its own subclass. When you implement prepareForReuse
in your subclass, set them all to hidden, and in your setObject
call, determine which ones need to be unhidden.
Try this
- (void)prepareForReuse {
[super prepareForReuse];
[_photoImage unsetImage];
}
精彩评论