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
4 answers

tableview dequeue reusable cell overlaps

I have a custom table view cell class. I dynamically create uiviews and uilabels and uiimageview to cell and alloc and init them with frame.contentView. But on scroll because of reuse they get overlapped and label's text and other properties get…
meteors
  • 1,747
  • 3
  • 20
  • 40
0
votes
1 answer

does not have a member called dequeueReusableCellWithIdentifier

I cant make my code work properly, it keeps saying "UITableView!, numberOfRowsInSection: int) -> Int' does not have a member named 'dequeueReusableCellWithIdentifier'" Would be happy if someone could explain this :) Here's my swift file: import…
Marius Hegg
  • 99
  • 10
0
votes
1 answer

Each cell with different layout in TableView, how is scroll optimised?

If I have a UITableView with each cell having a different layout. For example, cell 1 has one text field, cell two has two text fields and so on, in this case height of tableview cell varies based on how many text fields it has one below the other.…
Vinuta
  • 575
  • 4
  • 18
0
votes
2 answers

UI control not display content in custom tableviewcell with storyboard

I don't understand why the label i had in my storyboard don't show up when a run the app with IOS8 and XCODE 6.1.1 I have bound my label to a custom UiTableviewCell and i can set the text but my label don't appear in the subview of the content view…
0
votes
0 answers

iOS - Is it possible to have different versions of UIView subclass in one XIB file? (Similar to UITableViewCell Prototypes)

I created a custom notification view (UIView Subclass) in a XIB file. However, I want to have multple types (i.e. one would have one UILabel, another would have 2 UILabels for Title and Subtitle, etc.) I do this a lot in UITableViewCells using…
JimmyJammed
  • 9,598
  • 19
  • 79
  • 146
0
votes
1 answer

Objective-c Removing a reuseIdentifier from a UITableViewCell

I have a custom UITableViewCell that has data that I get from the server. I set the reuseIdentifier of the cell when the data comes in. Everything works fine, until I do a pull down to refresh and get new/updated data. The identifier from the server…
The Guardian
  • 374
  • 1
  • 7
  • 22
0
votes
2 answers

UICollectionView reorder cells after scrolling

I have added this UICollectionViewDelegate with my implementation: - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath { SAPCollectionViewCell *collectionViewCell =…
Matrosov Oleksandr
  • 25,505
  • 44
  • 151
  • 277
0
votes
1 answer

UiButton state keeps changing when scrolling in UITableview

I know there are a few posts abou this but I am still confused why the button i created in a tableview wont keep its state when its selected. When I scroll, unselected buttons get affected and it changes back and forth. Please help. -…
user3926564
  • 105
  • 1
  • 1
  • 6
0
votes
3 answers

UITableViewCell Reusing Dobut

I have this little doubt about reusing UITableViewCell. When we create UITableViewCell it kinda looks like following. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString…
slonkar
  • 4,055
  • 8
  • 39
  • 63
0
votes
1 answer

Reusable Cell is repeating same indexPath for many cells

I'm using a UITableView and a custom cell.when i click one cell it goes to the back screen and i save the indexPath in a NSIndexpath ; when again i navigate to tableView i change backgroundColor of the previously selected cell so user can Identify…
Parinita
  • 87
  • 2
  • 13
0
votes
2 answers

How to get reference to current UITableViewCell

At my experiment I need to have reference to first UITableViewCell in tableView. By some action I need to set image and some other cell properties and to keep this state of this only cell even if the tableView will be scrolled. All of this…
Alex Thumb
  • 45
  • 6
0
votes
1 answer

Assertion failure when trying to create a UICollectionViewCell

I'm trying to create a UICollectionView with a customize nib. To do that, I'm doing the same thing I'm doing with UITableView : MyCollectionViewController.m - (void)viewDidLoad { [super viewDidLoad]; myCollectionView.delegate = self; …
Nicolas Roy
  • 3,773
  • 5
  • 27
  • 42
0
votes
8 answers

UItableView Cell Resuablity Data getting interchaged while scrolling

Hi All, - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = @"Cell"; UITableViewCell *cell = [tableView…
iOSDev
  • 412
  • 10
  • 30
0
votes
1 answer

Using multiple identifiers in UICollectionViewCell

I want to use multiple identifiers in UICollectionViewCell. But it seems like I can set just one reuse identifier for CollectionView. [collectionView registerClass:[CollectionViewCell class] forCellWithReuseIdentifier:@"CollectionViewCell"]; It…
0
votes
1 answer

UICollectionViewCell reuse issue

I have a storyboard and one of my viewControllers has a CollectionView. I have a prototype cell that has a label inside. I created a class for that prototype cell in order to have access to the label via an IBOutlet property. The problem is that I…
Ilea Cristian
  • 5,741
  • 1
  • 23
  • 37