zoukankan      html  css  js  c++  java
  • 【Thread 1: signal SIGABRT】:UITableView、UICollectionView自定义Cell单元格之前,必须注册Cell

    ★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★
    ➤微信公众号:山青咏芝(let_us_code)
    ➤博主域名:https://www.zengqiang.org
    ➤GitHub地址:https://github.com/strengthen/LeetCode
    ➤原文地址:https://www.cnblogs.com/strengthen/p/12141815.html
    ➤如果链接不是山青咏芝的博客园地址,则可能是爬取作者的文章。
    ➤原文已修改更新!强烈建议点击原文地址阅读!支持作者!支持原创!
    ★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★

    错误提示:

    Thread 1: signal SIGABRT

    CustomCell是自定义的UITableViewCell或UICollectionViewCell

    在复用单元格之前必须注册Cell。

    UITableView注册Cell

    collectionView.register(CustomCell.self,forCellWithReuseIdentifier:cellIdentifier)

    UICollectionView注册Cell

    tableView.register(CustomCell.self,forCellReuseIdentifier:cellIdentifier)

    之后才可以编写复用代码!

    UITableView自定义单元格初始化方法:

     1 //重写单元格的自定义方法,在该方法中对单元格进行自定义操作
     2 override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?)
     3 {
     4     //首先实现父类的初始化方法
     5     super.init(style: style, reuseIdentifier: reuseIdentifier);
     6 }
     7 
     8 required init?(coder: NSCoder) {
     9     fatalError("init(coder:) has not been implemented")
    10 }

    UICollectionView自定义单元格初始化方法:

    1 override init(frame: CGRect) {
    2     super.init(frame: frame)
    3 }
    4 
    5 required init?(coder aDecoder: NSCoder) {
    6     fatalError("init(coder:) has not been implemented")
    7 }
  • 相关阅读:
    转 sql 时间转换格式 convert(varchar(10),字段名,转换格式)
    C#页面添加提交数据后跳出小弹窗的功能
    解决粘包问题
    粘包问题
    模拟ssh远程执行命令
    基于TCP协议的socket套接字编程
    Linux和git使用
    osi七层协议
    TCP协议的三次握手和四次挥手
    C/S 和 B/S架构
  • 原文地址:https://www.cnblogs.com/strengthen/p/12141815.html
Copyright © 2011-2022 走看看