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
2
votes
2 answers

iOS Swift UICollectionView registerNib for reuseable view not working

I am trying to use a create a iCalendar lookalike using a UICollectionViewController. Right now I am trying to add reuseable views as column headers for each day. I made a storyboard and added a UICollectionViewController which is linked to this…
Phil Niedertscheider
  • 1,068
  • 11
  • 29
2
votes
1 answer

Reusing table view cells in a Mac application

I am currently trying to convert my iOS application onto the Mac and therefore I would like to replicate some of the behaviours from the iOS version. In the mobile application I use dynamic table view rows with regards to content and height and when…
the_critic
  • 12,720
  • 19
  • 67
  • 115
2
votes
2 answers

Correct subclassing and reusing of UITableViewHeaderFooterView

I have a UITableView where I have section headers that can be tapped to expand or collapse the section. In my particular example each section only has one row, which is either visible (section expanded) or hidden (section collapsed). As section…
Skyrocker
  • 35
  • 1
  • 5
2
votes
2 answers

How to assign different identifiers for different cell styles in one uitableview?

I'm a freshman in ios development, I want to implement different cell styles in different sections in one uitableview. And my tableview have two sections, each section have three rows. I know different cell should have different reuseidentifier to…
Andy_24
  • 1,353
  • 2
  • 12
  • 20
1
vote
1 answer

UITableView dequeueReusableCellWithIdentifier: returning nil

I have an application that has a UITableView with various custom UITableViewCells (and cell identifiers). In my implemented tableView:cellForRowAtIndexPath: method I use the UITableView's dequeueReusableCellWithIdentifier: method and it gives me a…
ZeCodea
  • 1,071
  • 9
  • 26
1
vote
1 answer

Cell reuse identifier in nib does not match the identifier

My app crashes instantly as soon as it tries to make the table view, no idea what is wrong since the cell reuse identifier in nib matches the identifier used to register the nib. Would appreciate any help I'm using a virtual machine, so I can't…
sunled
  • 13
  • 4
1
vote
3 answers

Overhead of Disabling Cell Reuse

So I have 3 sections with 3 rows in each section (9 rows overall), and each row as a textField. I had some problems with the tableView and it was very annoying as the cells gets mixed up with values, when I scroll up and down, and the whole…
Legolas
  • 12,145
  • 12
  • 79
  • 132
1
vote
1 answer

Why do my TableView cells need reuse identifiers?

To practice my programming and keep track of my progress I'm building an app for myself. I've created a tableview and for each section and independent cells for each requirement. Now Xcode is upset because each prototype cell doesn't have an…
1
vote
2 answers

UITableViewCell backgroundView gets reused when it shouldn't

I am wanting to add a custom background and selected background images for my tableview cells. Currently it seems that when the cells get reused, the background images get screwed up, the top cell will use the bottom cells image, etc etc. Am I…
Nic Hubbard
  • 41,587
  • 63
  • 251
  • 412
1
vote
2 answers

Issue with setting icon image in cell

I am trying to create a 'blank_star icon' in every cell of a table view, the star should become a 'solid' star after the user clicks on it. I have created a subclass of UIButton as seen below //.h file @interface Bleh : UIButton…
Zhen
  • 12,361
  • 38
  • 122
  • 199
1
vote
3 answers

How to detect if TableViewCell has been reused or created

In Swift with dequeueReusableCell API we don't have control over creating of a new instance of TableViewCell. But what if I need to pass some initial parameters to my custom cell? Setting parameters after dequeue will require a check if they have…
Anastasia
  • 3,024
  • 1
  • 23
  • 34
1
vote
1 answer

Set annotation's glyphtext based on the annotation's properties

I'm running into an issue with custom annotations displaying incorrectly. In my code, I check whether the current annotation is for a station with a given unique identifier. If so, I customize its properties. StationAnnotationView.swift class…
ohBoy
  • 119
  • 1
  • 10
1
vote
1 answer

objective-c: [self.tableview reloadData] reloads data but doesnt clear older cells

i'm working on a tableview and i am newbie in dynamically creating cells (i used to create them with IB and then link them to their tableviewcell controller etc..). Everything works great and recpected arrays are updated properly but when i fire…
dreampowder
  • 1,644
  • 3
  • 25
  • 41
1
vote
0 answers

Weird behavior with UICollectionView when reusing cells

===EDIT=== Ok! Finally I think I've made it working. When I was reading this article (http://matteomanferdini.com/the-correct-way-to-display-lists-in-ios-and-what-many-developers-do-wrong/#reuse), I wanted to apply best practice so I made some…
1
vote
0 answers

Table view's endUpdates() method behaves differently in iOS 11

I have a logic regarding the content in the cells of a UITableView where at some point I call tableView.endUpdates(). The behavior of my scenario was the expected in iOS 10, but now in iOS 11 I am seeing that is behaving in a different way. In iOS…
AppsDev
  • 12,319
  • 23
  • 93
  • 186
1 2
3
10 11