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

How to reuse custom UITableViewCell defined as a prototyped cell in Storyboard controller

I have the only cell template for items at two different UITableViewControllers/TableViews. What I need is to define it once and then reuse at other UITableView via UITableView.DequeueReusableCell(CellId); The issue is that is when I call this…
Mando
  • 11,414
  • 17
  • 86
  • 167
4
votes
1 answer

What method is triggered on a custom CollectionViewCell when dequeued from a reusable Cell?

I am dequeueing a reusable custom ItemCollectionViewCell as usual with the method from its parent ViewController - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath { …
zanona
  • 12,345
  • 25
  • 86
  • 141
4
votes
1 answer

iOS: UITableView mixes up data when scrolling too fast

I've subclassed the UITableViewCell to add custom appearance to it. At the init level of the MYTableViewCell I added 4 subviews: UIImageView, and three UILabel(s). All 4 subviews have a different Tag assigned to them. Inside the…
ymotov
  • 1,449
  • 3
  • 17
  • 28
3
votes
1 answer

Having issue in reuseable cell in UITableView cell

I have two kinds of design in single UITableViewCell. Here is the design which I want and getting at the time of loading viewController But after scrolling I'm getting following result. I think this problem is caused by reusability of…
NiravS
  • 1,144
  • 1
  • 12
  • 24
3
votes
2 answers

Register cell reuse identifier within XCode Playgrounds

Trying to play with Table in the XCode Playgrounds to understand how it works, because there a lot of stuff connected to the UITableView and a few tutorials describe these relations and inheritance under the scenes (like UIView -> UIScrollView ->…
Andrew V. Jackson
  • 273
  • 1
  • 4
  • 14
3
votes
1 answer

Show alternate views in each UITableViewCell - iOS

I've got 2 views in my UITableViewCell and I want to show alternate views in each cell (if previous cell has right view ON, then next cell will have left view ON). I've implemented it successfully, but on scrolling the tableview, alternating views…
Hyder
  • 1,163
  • 2
  • 13
  • 37
3
votes
4 answers

Scrolling UITableView with few different types of cells not smooth enough

I need to have few different cell types in one quite complex table view. I registered 10 xib's with those different cell classes with different reuse identifiers. The problem is that when I scroll the table view for the first time (from top to…
Leszek Szary
  • 9,763
  • 4
  • 55
  • 62
3
votes
2 answers

Prevent UITableViewCells from dequeue and reload

I am currently making an app which displays the user's profile. For that purpose, I used an UITableViewCell with custom cells for the different types of data (phone numbers, mail addresses, etc...). There is a maximum of 8 cells per profile. The…
Pierre
  • 372
  • 2
  • 16
2
votes
1 answer

What is the point of a reuse identifier for annotations

I am trying to implement annotation onto my mapkit I am using mapView.register(EventMarkerView.self, forAnnotationViewWithReuseIdentifier: MKMapViewDefaultAnnotationViewReuseIdentifier) However, I often see this sort of format func mapView(_…
thalacker
  • 2,389
  • 3
  • 23
  • 44
2
votes
3 answers

Xcode: How to find which cell has no reuse identifier

I have this warning: Prototype table cells must have reuse identifiers The project is pretty large and we have many tableViews and I cannot find the cell that causes this warning. Is there a way to find the source of this warning? I can see the…
user1269290
  • 451
  • 1
  • 6
  • 18
2
votes
0 answers

IOS/Objective-C: Reusing Cell Throws off Autolayout of Different Size Elements in TableviewCell

I am displaying feed items in a tableview. Depending on the item, the cell must be larger or smaller--for example larger to accomodate a photo or larger still if it references another feed item such as an article and I have to display the item…
user6631314
  • 1,751
  • 1
  • 13
  • 44
2
votes
1 answer

Not using reusable cell in UITableView with CollectionView in each cell

I have a UITableView and in its prototype cell have a UICollectionView. MainViewController is delegate for UITableView and MyTableViewCell class is delegate for UICollectionView. On updating each TableViewCell contents I call cell.reloadData() to…
Hadi Sharghi
  • 903
  • 16
  • 33
2
votes
1 answer

Custom cell will never be queued when loaded from Nib?

i am using the following logic to load a custom cell into my UITableView: static NSString* cust=@"CUSTOM"; LabelTextfieldTC *cell = (LabelTextfieldTC*)[tableView dequeueReusableCellWithIdentifier:cust]; if( cell == nil ) { …
2
votes
1 answer

UICollectionViewCell init with reuseIdentifier

I have a custom UICollectionViewCell, and I dequeue it from my view controller by registering it like so [self.calendarView registerNib:[UINib nibWithNibName:NSStringFromClass([DayCell class]) bundle:nil] forCellWithReuseIdentifier:dayCell]; and…
2
votes
0 answers

UICollectionView showing values from old cells when reusing

I have a UICollectionview which is loaded on the basis of the results of a serchbar in a previous UIViewController. In the cells of the collection I load images from the internet. When collectionView:(UICollectionView *)cv cellForItemAtIndexPath: is…
user3188554
  • 67
  • 1
  • 6
1
2
3
10 11