unable to dequeue a cell with identifier Cell - must register a nib or a class for the identifier or connect a prototype cell in a storyboard

前端 未结 22 2156
面向向阳花
面向向阳花 2020-12-12 17:33

I am fairly new to coding in general and really new to Xcode (Swift). I understand that I need to register a nib or a class but I don\'t understand \'where or how?\'.

<
22条回答
  •  鱼传尺愫
    2020-12-12 18:10

    Match the identifier name at both places

    This error occurs when the identifier name of the Tablecell is different in the Swift file and in the Storyboard.

    For example, the identifier is placecellIdentifier in my case.

    1) The Swift File

    override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
    
        let cell = tableView.dequeueReusableCell(withIdentifier: "placecellIdentifier", for: indexPath)
        
        // Your code 
    
        return cell
    }
    

    ###2) The Storyboard

提交回复
热议问题