Questions tagged [reuseidentifier]

In the Cocoa Touch platform, reuse identifiers are string values, supplied by the programmer, that define pools of similar view objects in for use with UITableView, UICollectionView, or MKMapView.

Great iOS apps must perform well in memory– and processor-constrained environments while displaying rich, high resolution content. Reuse identifiers are part of a caching mechanism employed by a few of the core data views provided by Apple to minimize the number of views to initially construct, based on the data currently visible in a scrolling view, without requiring constant reconstruction of views as the user scrolls or pans through data.

The following view classes employ reuse identifiers:

The programmer first identifies the class of the view to use for a given reuse identifier. This can be done in a few ways:

  • By configuring prototype cell views with reuse identifiers and class names in a storyboard
  • By mapping reuse identifiers to classes or nibs in methods such as registerClass:forReuseIdentifier:
  • By manually instantiating new cell or annotation objects with a given reuse identifier value

When the table/collection/map view displays the initial set of data, or it displays new data due to user interaction, it will ask its delegate to create views for each item to display. The delegate will typically use a "dequeue" method such as dequeueReusableCellWithIdentifier: to get an instance of the right type of view, then customize the view for the specific data to display, and return that view. If there is an existing view object with the given reuse identifier that is not currently visible on screen, it may be returned from the "dequeue" method so that it can be reused; otherwise, a new view object will be created with the given reuse identifier.

152 questions
1
vote
1 answer

How to declare class attributes in swift, just like UITableViewCell reuse identifiers?

I am trying to declare a reuse identifier associated to a UITableView subclass in swift. From my understanding I would like to declare an class stored property (not an instance one) so i have access via: MyCustomTableCell.ReuseIdentifer. Here is…
martin
  • 125
  • 1
  • 1
  • 7
1
vote
1 answer

CollectionView, TableView registered classes for reuse identifiers

I want to know which classes are registered with a UITableView or a UICollectionView with reuse identifiers is it possible to find this info? I've checked the class references and didn't find anything. I wanted to unregister certain classes from…
Lena Bru
  • 13,521
  • 11
  • 61
  • 126
1
vote
1 answer

iOS Collection View Cells: Strong references during reuse / prevent cell reuse?

Question: What happens to references to a collection view cell when it is scrolled offscreen and reused? All my attempts to supply cells without using "dequeue" have failed. Is there a way to tag a cell as non-reusable, so the collection will keep…
1
vote
3 answers

iOS: Cell content not being cleared with reuseidentifier

I'm trying to build a table with cells that list an array in UILabels. So each cell will have its size and amount of labels determined by the number of objects in that array. However, I'm running into an issue where the content is initially input…
Ian Gray
  • 387
  • 1
  • 3
  • 15
1
vote
2 answers

Best practice in UITableView with different kind of UITableViewCell

her's what we need to do: the data source of the tableView core data. a tableView that contain 5 different type of custom tableViewCell. every tableViewCell is completely different from others. some tableViewCell will have a progressBar. we have 3…
Red Mak
  • 1,176
  • 2
  • 25
  • 56
1
vote
1 answer

reuse issue in UITableView

I have UITableView which covers whole screen (480px). Each cell is of height 300px. I have total 5 rows. Below is the code what I have used. -(UITableViewCell *) tableView:(UITableView *) tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { …
Fahim Parkar
  • 30,974
  • 45
  • 160
  • 276
1
vote
1 answer

iOS: UITableViewCell reuse, image of button changing

I know this has been widely discussed before, and I'm sure, I'm just missing something simply, but like many others before me, I have an issue with cell reuse in a UITableView... I have a button that displays an avatar, and I asynchronously download…
user969043
  • 756
  • 2
  • 13
  • 34
1
vote
2 answers

Reusable cell in UITableView

I'm using a UITableView and a custom cell with a checkbox. I have more than 1 section. When a check a checkbox in the first section, for example the cell with row = 0 and section = 0, I save the data and it works. But the cell in the row = 0 and…
Lapinou
  • 1,467
  • 2
  • 20
  • 39
1
vote
1 answer

UITableView and Cell showing content on wrong place

I have two problems with my tableview, namely, the "Go Home" button from the tablefooterview is showing up (in the middle of the screen) when the end of the tableview isn't reached yet. As you can see in the first picture, the home button is…
Fuzej
  • 97
  • 1
  • 11
1
vote
1 answer

Change CellReuseIdentifier Based on section

I have a UITableView and a number of .xibs with different table view styles. Each .xib has it's own class and is registered with a reuse identifier based on the section. For example: In my viewDidLoad I have the following: UINib *cellStyleOne =…
CoreCode
  • 2,227
  • 4
  • 22
  • 24
1
vote
2 answers

UITableViewCell using reuseidentifier giving unwanted result with callback block

When the callback block for loadImage is run below, the table cell may have since been reused. So the image is applied to "imageView" is not relevant to this reused cell, it's the image for the old cell. If I make the identifier unique for each cell…
0
votes
1 answer

dequeueReusableCellWithIdentifier: Remembering State of Cell

I've embedded horizontal table views inside of table cells (ala the Pulse Reader). The interesting behavior that I'm getting is that dequeueReusableCellWithIdentifier: seems to be correctly remembering the offset of the embedded table views,…
Tyler DeWitt
  • 23,366
  • 38
  • 119
  • 196
0
votes
1 answer

Getting rid of strings as reuse identifiers (AnyClass issue)

Using string identifiers for reuse cells cause a lot of problems... I tried getting rid of them (in way described here: https://medium.com/bleeding-edge/nicer-reuse-identifiers-with-protocols-in-swift-97d18de1b2df): protocol ReuseIdentifiable { …
0
votes
1 answer

Unexpected crash in CollectionView iOS

I found a crashed on crashlytics that comes from users but is not reproducible at my end. The projects uses collectionviews at multiple places and I have even verified the cell class being set correctly in storyboard. Note: The Code uses…
Prathamesh
  • 56
  • 4
0
votes
1 answer

How to set the metadata of LPLinkView to nil

I'm using LPLinkView in a tableview cell. While scrolling the reused cell initially displays the LinkProvider of the recycled cell and then changes as soon as the network call completes. I want to prepare the cell for reuse. Is there a way to set…