Swift 'Unable to Dequeue a Cell with Identifier Intervalcellidentifier

Swift 'unable to dequeue a cell with identifier intervalCellIdentifier

1. With XIB file

You have to register the cell to table first, may be in viewDidLoad, as:

let nib = UINib(nibName: "CustomCell", bundle: NSBundle.mainBundle()) 
tableView.registerNib(nib, forCellReuseIdentifier: "CustomCellIdentifier")

This is applicable if we are using a custom cell with .xib file.

2. Without XIB file

And here is a solution if we are not creating separate .xib file for custom cell:

We need to create dynamic prototype for cell in table view as:
Sample Image

Then we need to provide class name and reuse identifier for our custom cell as:
Sample Image

Sample Image
Here, no need to register class or nib!


Here is the cellForRowAtIndexPath implementation:

override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {

// Configure the cell...
let cell = tableView.dequeueReusableCellWithIdentifier("CustomTableViewCellId", forIndexPath: indexPath) as! CustomTableViewCell
cell.setCellIndexLabel(indexPath.row)

return cell
}

This implementation will be same for both the above solutions.


3. Only Class Implementation
Without XIB, without Dynamic Prototype

Here is the custom cell without any XIB or Dynamic Prototype:

class WithoutNibCustomTableViewCell: UITableViewCell {

override init(style: UITableViewCellStyle, reuseIdentifier: String?) {
super.init(style: style, reuseIdentifier: reuseIdentifier)
//do custom initialisation here, if any
}

required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}

override func awakeFromNib() {
super.awakeFromNib()
// Initialization code
}

override func setSelected(selected: Bool, animated: Bool) {
super.setSelected(selected, animated: animated)

// Configure the view for the selected state
}

class func identifier() -> String {
return "WithoutNibCustomTableViewCellId"
}

//MARK: Public Methods
func setCellIndexLabel(index: Int) {
let customLbl = UILabel(frame: CGRectMake(0, 0, 100, 40))
customLbl.text = String(index)
contentView.addSubview(customLbl)
}

}

Then, in table view, we need to register cell class as:

tableView!.registerClass(WithoutNibCustomTableViewCell.classForCoder(), forCellReuseIdentifier: WithoutNibCustomTableViewCell.identifier())

cellForRowAtIndexPath also same as above, like:

let cell = tableView.dequeueReusableCellWithIdentifier(WithoutNibCustomTableViewCell.identifier(), forIndexPath: indexPath) as! WithoutNibCustomTableViewCell
cell.setCellIndexLabel(indexPath.row)
return cell

unable to dequeue a cell with identifier cell with properly defined identifier

It seems that issue was in custom library i was using for navigation. Instead initialising view controller from storyboard identifier, it was initialising class directly, thus storyboard view controller was useless.

Everything works well now.

Trouble with simple TableView in Swift, error SIGNAL SIGART

You did not added the Prototype Cell into the Table View, Drag and Drop the table view cell into the table view and connect the Table View Cell class to it with particular identifier.

Drag and Drop a TableView Cell and Assign a class:

Sample Image

Assign the identifier to it:

Sample Image

Set the Table Style to Basic

Sample Image

Cell reuse identifier in nib does not match the identifier

Looking at the crash -
Sample Image

It looks like -

  1. CustomTableViewCell.xib has the CutomTableViewCell value in the reuse identifier.
  2. When you did the tableView.registerNib call, you used CustomTableViewCell in the reuse identifier.

These reuse identifier values must match.

iOS9 beta - SKEffectNode/CIFilter bug?

I reported the issue to Apple. It was a bug and they fixed it with iOS9 beta 5.

Screen is blank white when started on the Xcode simulator [swift 3.0]

Vertex Shaders generally run directly on the GPU for which it's compiled. In this case the iOS simulator doesn't physically have the GPU it needs to work with, hence the white screen.

Usually if you run the code on the physical device it should work, so try running there. Also check out this other question/answer with a similar error that might be of interest.

A vertex shader is simply a tiny program that runs on the GPU, written
in a C++ like language called the Metal Shading Language.

↳ Metal Shading Language Specification



Related Topics



Leave a reply



Submit