Questions tagged [prepareforreuse]
33 questions
31
votes
2 answers
What is the correct way to use prepareForReuse?
Need help with understanding how to use prepareForReuse() in UIKit.
The documentation says
you should only reset attributes of the cell that are not related to
content, for example, alpha, editing, and selection state
but what about resetting…

Kira
- 387
- 1
- 3
- 8
7
votes
1 answer
TableViewCell doesn't reload as expected
I have a little app that tracks players playing time in a sports game. I have a list of sports games, and you can click into one and start tracking game details. I'm trying to make it so that if a game is in progress and a user goes back to the list…

Jonnny
- 4,939
- 11
- 63
- 93
6
votes
3 answers
how to redraw non-visible UICollectionViewCell's after rotation ready for when reuse occurs?
How to redraw non-visible UICollectionViewCell's ready for when reuse occurs???
One approach I thought of was per the code in the Layout Cell prepareForReuse function, however whilst it works it non-optimal as it causes more re-drawing then…

Greg
- 34,042
- 79
- 253
- 454
4
votes
2 answers
NSLayoutConstraints is not respected in UITableViewCell
I have a UITableViewCell with an UILabel and an UIImageView. The image can be visible or hidden.
Here is my storyboard:
There's two constraints on the trailing part of the UILabel, one (a) that is equal to 8 with the UIImageView, another one (b)…

magohamote
- 1,484
- 1
- 17
- 29
2
votes
1 answer
Reusing cells in UITableView
I have my custom cell 'NewsCell'. It contains my custom view 'ImageMosaicView' (that is just subclass of UIView). I use it to show photos like in post in Facebook. I just pass images' urls to ImageMosaicView's instance, and it loads it and shows.
I…

Ponomarenko Artur
- 47
- 1
- 5
2
votes
1 answer
prepareForReuse is not working properly with imageView
I am trying to add a bottom border to a imageview, whenever my isLive function returns true. I checked the part, and it gets executed only once. However there are multiple cells with a blue bottom border. This code looks like…

Fabio ha
- 553
- 1
- 8
- 29
2
votes
1 answer
Why app crashes with [NSObject(NSObject) doesNotRecognizeSelector:]?
The app sometimes crashes with [NSObject(NSObject) doesNotRecognizeSelector:], the selector being [UIImageView setImage:].
I captured it by setting an exception breakpoint and the crash happens when setting an UIImageView.image in prepareForReuse…

Manuel
- 14,274
- 6
- 57
- 130
2
votes
1 answer
Values Repeat When Scrolling in TableView
When I tap a button in a custom cell and then scroll down (or up) another cell button is also tapped. I see that it's tapped because the button outlet that I created for the button is disabled.
My cellForRowAtIndexPath has a reuseIdentifier for the…

Lukesivi
- 2,206
- 4
- 25
- 43
1
vote
0 answers
Hide Views Function got called on cells that i dont want
In my CollectionView I am trying to hide content of cells which indexPath is more than 0, by calling blockContent func on cell. But somehow, after going back and forth threw cells, this func got called even on the first cell. How can i Fix it?…

Togosling
- 21
- 1
1
vote
0 answers
Should I use prepareForReuse of UITableViewCell if the cell is built by UIContentConfiguration?
I try to use the new Architecture for the building cell of UITableView, but I can't understand whether should I use prepareForReuse for this case, because I don't understand how
My cell :
class CustomTableViewCell: UITableViewCell {
static let…

Ice
- 680
- 1
- 10
- 23
1
vote
0 answers
Wrong cell data if fast scroll CollectionView swift 5
Can anybody help me with CollectionView? I parce JSON from some API, and get String values - title and image adress, then assign that Data to custom collectionViewCell in method cellForItem(). BUT than i fast scroll the collection view some cell…

Dmitry Chaschin
- 11
- 2
1
vote
2 answers
Reset collectionviewcell which is in tableView on prepareForResue
I have a (horizontal) collectionView which is in tableViewCell.
My tableViewCell row has a label and collectionView
Collectionview has button in each cell
When button is tapped, I highlight the button's color and tableCell's row which is perfectly…

Ashh
- 569
- 1
- 6
- 28
1
vote
1 answer
UICollectionViewCell is populated with previous cells data before new the cell's data loads, need to implement PrepareForReuse()
I have a problem with my UICollectionView, The problem is that if you scroll fast enough (not even that fast) the data that was in the cell before the reuse gets displayed for a second or two before the new data gets displayed.
This is the video of…

willscarter
- 67
- 9
1
vote
0 answers
ReactiveTableViewCell with dynamic height against cell reuse : how to avoid falling in an infinite loop?
So here's the description of the loop my app keeps falling on:
There is a UITableView containing ReactiveTableViewCell's (but I think RX part doesn't really matter here, so let's pretend these are UITableViewCell). Each cell embeds a UITextField…

leeyo
- 31
- 4
1
vote
3 answers
Resetting UITableViewCell Not working properly / Unselected Cells appears selected after scrolling
Problem is when I am scrolling the tableview after selecting a collectionViewCell (violet color on date 28). Few CollectionViewCells at the bottom of tableview appears to be selected (Here CollectionView is present inside TableView).
Code is like…

Shivam Tripathi
- 1,405
- 3
- 19
- 37