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
50
votes
3 answers

iPhone - What are reuseIdentifiers (UITableViewCell)?

From the official documentation: The reuse identifier is associated with a UITableViewCell object that the table-view’s delegate creates with the intent to reuse it as the basis (for performance reasons) for multiple rows of a table view. It is…
quano
  • 18,812
  • 25
  • 97
  • 108
34
votes
3 answers

UITableView dequeueReusableCellWithIdentifier Theory

When apple developed the UITableView for the first iPhone they had a problem in performance when scrolling through it. Then one clever engineer discovered that the cause of this was that allocation of objects comes with a price, so he came up with a…
Mark
  • 16,906
  • 20
  • 84
  • 117
30
votes
4 answers

initWithFrame : reuseIdentifier : is deprecated

In my project i've got a Deprecations warning, initWithFrame : reuseIdentifier : is deprecated I don't know what it mean, could some one tell me how to resolve this warning thanks here is the short code - (UITableViewCell *)tableView:(UITableView…
a3116b
  • 337
  • 1
  • 5
  • 13
11
votes
5 answers

Beginner in Xcode; reuse identifiers?

I have recently started to build a very basic To-Do List in Xcode 5 as my first project. Having practically finished the UI design and build I am now stuck on the implementation of data into my TableView. I have added a list of 13 items in my list…
user3804662
  • 121
  • 1
  • 1
  • 3
8
votes
1 answer

How to restore bindings in UICollectionViewCell after it is decoded

I have a subclass of UICollectionViewCell. The cell is visually designed in the storyboard with lots of components and these components are bound to the variables in Swift subclass using the storyboard. The Swift class just provides logic for…
rghome
  • 8,529
  • 8
  • 43
  • 62
7
votes
2 answers

UITableView separators drawn incorrectly through cell reuse?

I'm working on an iOS 5 project with storyboards, and thus using dynamic table cell prototypes in IB. In one of the views, I've got a table view with variable-height cells, with the cell height calculated from the height of the…
JK Laiho
  • 3,538
  • 6
  • 35
  • 42
7
votes
2 answers

UITableView and Cell Reuse

I have a UITableView and I've subclassed UITableViewCell (called it CustomCell) so it has several labels and a UIImageView. Only certain cells will actually display an image. Here's my code for tableView:cellForRowAtIndexPath:: - (UITableViewCell…
Dominic Williams
  • 1,538
  • 2
  • 13
  • 17
7
votes
2 answers

dequeueReusableCellWithIdentifier:forIndexPath: VS dequeueReusableCellWithIdentifier:

I have read this question and think that I understand the difference between the two methods until I find a strange example: Set table view cell's style be Basic, Identifier be Cell in Storyboard, code as below: import UIKit class…
fujianjin6471
  • 5,168
  • 1
  • 36
  • 32
7
votes
8 answers

How to purge a cached UITableViewCell

Does anyone have suggestions on how to purge a cached UITableViewCell? I'd like to cache these cells with reuseIdentifier. However, there are times when I need to delete or modify some of the table rows. I expect to call reloadData after the row…
iPhone dev
5
votes
4 answers

UITableViewController changing one reusable cell affects other cells

I have a very simple UITableViewController subclass designed to show users the characters in the alphabet in cells. When the user presses on a cell, it is to set its accessory type to a checkmark. #import "MTGTableViewController.h" @interface…
michaelsnowden
  • 6,031
  • 2
  • 38
  • 83
5
votes
0 answers

Update UILabel-Subview of MKAnnotationview

I have a MapView with cluster annotations (ADMapCluster). I want to show the amount of elements in the Cluster, therefor I'm adding a UILabel to the MKAnnotationView as a Subview. My Problem is that when I reuse the MKAnnotationView after zooming…
5
votes
2 answers

Why does a manually reused UITableViewCell disappear on row-reload?

If I keep a fixed UITableViewCell with reuseidentifier=nil as an ivar and return this instance for a specific row, and then reload this row specifically using [tableView reloadRowsAtIndexPaths:withRowAnimation:], the row contents disappear (or…
Hannes
  • 51
  • 3
4
votes
2 answers

iOS - UITableView not displaying cells

I have the following interface set up in storyboard: The controller is a custom controller that extends from UITableViewController. When I run my app this is what I get: I thought it might have something to do with the Reuse Identifiers so I…
8vius
  • 5,786
  • 14
  • 74
  • 136
4
votes
2 answers

How to NOT reuse cells in UICollectionView - Swift

I have UICollectionView in a cell of UITableView. This UICollectionView displays user's profile photos. There are only a few items there (let's assume 10 photos is a maximum). So, I do not want to reload images from backend every time cell reusing.…
4
votes
1 answer

tableview cell disappears when scrolling

This problem does not necessarily occur Sometimes it disappears when sliding and sometimes does not disappear more information here click to show gif click to show storyboard png code HSubjectCell *cell = [tableView…
1
2 3
10 11