ios - 如何修复错误 "Thread 1: EXC_BAD_ACCESS (code=2, address=0x7ffeeca55ff8)"

标签 ios swift xcode uicollectionview xcode11

我正在构建一个使用 UICollectionView 的应用程序,但是当我注册我的 Cell 时,它给了我错误,

Thread 1: EXC_BAD_ACCESS (code=2, address=0x7ffeeca55ff8)

我不知道这意味着什么,请有人帮助我吗?很抱歉,如果我没有提供足够的代码,请询问我是否需要更多。这是我的代码:

import UIKit

class ThingsToDoCollectionView: UICollectionView {

override func register(_ cellClass: AnyClass?, forCellWithReuseIdentifier identifier: String) {

    register(UICollectionView.self, forCellWithReuseIdentifier: "ThingsToDoCollectionViewCell")

    }


}

编辑:这是我的 ThingsToDoUICollectionViewCell 的代码

导入UIKit

class ThingsToDoCollectionViewCell: UICollectionViewCell {


@IBOutlet weak var GIDThumbnail: UIImageView!
@IBOutlet weak var GIDTitle: UILabel!
@IBOutlet weak var GIDDueDate: UILabel!


}

最佳答案

您应该在具有 UICollectionView 的 UIViewController 的 viewDidLoad 方法中注册单元格

self.collectionView.register(UINib(nibName: "YourCellXIBFileName", bundle: nil), forCellWithReuseIdentifier: "YourCellReuseIdentifier")

关于ios - 如何修复错误 "Thread 1: EXC_BAD_ACCESS (code=2, address=0x7ffeeca55ff8)",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56509967/

相关文章:

ios - 如何使操作表在调用时使周围的 View 变暗?

iphone - iAd 错误 "Ad inventory unavailable"

swift - 如何更改用户代理?

objective-c - 为什么我会收到此错误?在 Xcode

ios - Selector 方法必须与观察者所在的实例相同吗?

ios - 在 Swift 中使用自动布局时获取错误的 tableVIew.contentSize

ios - 如何使我的页面 View Controller 不至于无穷无尽?

ios - 为什么 MPMoviePlayerController 全屏按钮图标在 iOS 10 中变为字幕图标?

ios - 滑出菜单 - 切换回原始 Controller 时,导航栏消失

ios - 使用 Swift 在 Xcode 6 中使用 xib 在自定义 uiview 中获取 SIGABRT