I know this question is dumb. But suddenly stuck in this matter.
When I use dequeReusableCellWithIdentifier , the cells are reused. To be more specific, first the 'n' cell set is reused along with its links
Since the same links are reused, I cannot actually store local variables in cells. I really need to assign them every time in cellForRowAtIndexPath
Suppose I use the UITableviewcell user complex. (I know we need to reduce complexity, but still ...)
Some views must be added to the cell.
The best example I could think of is an image slider.
Thus, the number of images on the image slider depends on the data source. Therefore, I need to add views to cellForRowAtIndexPath. I can’t avoid it.
Since the same cell reference is being reused, I need to add these views every time cellForRowAtIndexPath is called. I think this is a heavy load.
I was thinking about using drawRect method , but it does not work with UITableViewAutomaticDimension
If I do not use dequeReusableCell, I will have separate reference cells, but it will cost memory and performance.
So what is the best solution? Can I use dequeReusableCell and still do not need to rewrite its contents?
1:
dequeReusableCell, dequeueReusableCellWithIdentifier - forIndexPath. .
2:
, .
, view.
cellForRowAtIndexPath dequeueReusableCellWithIdentifier - forIndexPath
, , , , , cellForRowAtIndexPath.
, n . "n" . .
, tableView cellForRowAtIndexPath, .
, .