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
0
votes
1 answer

How to set nil value for reuseidentifier for uitableview cell while dequeueReusableCellWithIdentifier?

Hi I am loading nib file for uitableview cell in swift. I am registering cell but for that want to use nil ReusableCellWithIdentifier. Because I don't want to reuse cell. In objective -C we can pass nil value in ReusableCellWithIdentifier to stop…
Mayur Mehta
  • 99
  • 1
  • 9
0
votes
1 answer

Incorrect cell data when scrolling UITableView

I have a UITableView, which cells are UICollectionViews(a horizontal slider). Each UITableViewCell contains vary number of items. For example, the first row of the UITableView contains 3 pictures, the second row contains 2 pictures, and the third…
Kesong Xie
  • 1,316
  • 3
  • 15
  • 35
0
votes
1 answer

UICollectionView with randomized reuseIdentifiers in 1 section

I have a UICollectionView with 16 cells. 1 of the cells (the Game Over cell) must be random. I would like to randomize the Game Over cell in the collection view. I have it somewhat working by using different sections, but that defeats the purpose of…
Joe
  • 3,772
  • 3
  • 33
  • 64
0
votes
4 answers

UITableview - Setting a property for cell is messed up with reused cells

I have a UITableView which act as a form. It has about 20 cells (with static content but dynamic cells). So I had an array with the fields and loading it in the table view. At some time the user will press the "Submit" button and I need all the…
BlackM
  • 3,927
  • 8
  • 39
  • 69
0
votes
1 answer

reloadRowsAtIndexPath setting different cell at reuse

I am reloading a cell using reloadRowsAtIndexPath when a button in that cell is pressed. Then tableView delegates are getting called twice. When I press the button first time, one of my subviews is getting removed. On second press, it is restored.…
0
votes
1 answer

Toggle cell size button not changing cell identifier UIViewController

i have created some code in my button to toggle between my cell identifier of which does so pretty well but obviously i needed to set and initial cell identifier of which is small icon, so how would i go about remove that cell identifier and…
0
votes
1 answer

Swift custom cell if else to change between label textbox

I have a table view that has a custom cell class that has 2 labels & a textbox the result set would display one of the labels for all rows (a name) then there is a if else statement to show either the second label or a textbox. example label 1 …
Brian
  • 13
  • 4
0
votes
0 answers

AVPlayerLayer in Reuse UITableViewCell

I have a logic of playing videos in the cells. Each time you do play in a cell and move the scroll quickly, the player reappears again. (because dequeueReusableCellWithIdentifier). It occurred to me save the section and row of the cell and ask why…
jose920405
  • 7,982
  • 6
  • 45
  • 71
0
votes
1 answer

UICollectionView reuseIdentifier in sizeForItemAtIndexPath - swift

I have the following code, which puts a collection view into either one or two columns, depending the size of the screen: func collectionView(collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout,…
Ben
  • 4,707
  • 5
  • 34
  • 55
0
votes
1 answer

UICollectionView Reorders And Changes Selected Item

I'm currently facing a problem where my collectionView changes the order of my items when they scroll off the screen and switches the selected cell. At the moment they're organized so that they scrolls vertically (and there are two items side by…
KingPolygon
  • 4,753
  • 7
  • 43
  • 72
0
votes
2 answers

Fourth UITableViewCell reusing height from first cell

I have a TableView that retrieves images from Parse. The image aspect ratios vary. I have it set up so that the width of the image is changed to match the width of the users device and the height will adjust to match the aspect ratio. My problem is,…
0
votes
2 answers

Table view content missing during scrolling

I am using table view cell and adding a pop up view on clicking a button placed in cell .But when I am scrolling the table view view pop is disappearing from my cell. Here is my code: - (UITableViewCell *)tableView:(UITableView *)tableView…
RakeshBiswal
  • 59
  • 10
0
votes
2 answers

Repeated content in custom TableCells in different sections

I have an *UITableView that show events in a period of time, some kind of calendar. Each section is a day of the week and each event is a custom *UITableViewCell. The events are inside of an *NSArray, and depending on their date and time, those…
PerroVerde
  • 49
  • 8
0
votes
1 answer

Xcode adding new TableView cell adds new cell but shows deleted cell's textfield

I have a tableview that displays cells. Some of these cells have to be removed with a toggle button and then some are added in. So I have 4 cells in my 3rd section. Their titles in ascending order are follows: same?, start, end, duration. The second…
Michael
  • 11
  • 4
0
votes
2 answers

Reusing custom UITableViewCells, see old UIView pictures briefly before new pictures load

I have a custom UITableViewCell that contains a UIView, in which I display a couple of pictures. In my tableView:cellForRowAtIndexPath: function, I call dequeueReusableCellWithIdentifier: to reuse old custom cells, and then I update them with new…