【问题标题】:error: Execution was interrupted, reason: internal ObjC exception breakpoint(-5)错误:执行被中断,原因:内部 ObjC 异常断点(-5)
【发布时间】:2018-07-21 06:25:42
【问题描述】:

我正在尝试使用自定义 UICollectionViewCell 显示 UICollectionView,应用程序崩溃并且我收到以下错误:

2018-07-21 09:14:10.498749+0300 Shippers[18104:819840] *** -[NSISEngine _optimizeWithoutRebuilding] 中的断言失败,/BuildRoot/Library/Caches/com.apple.xbs/Sources/Foundation_Sim/ Foundation-1452.23/Foundation/Layout.subproj/IncrementalSimplex/NSISEngine.m:1888 错误:执行被中断,原因:内部 ObjC 异常断点(-5).. 进程已经返回到表达式求值前的状态。

这个RankingVC 被添加为 ChildViewController。不确定问题出在哪里,但如果我注释掉文件中的所有UICollectionView 内容,应用程序不会崩溃,所以一定有问题。

class RankingVC: UIViewController {

@IBOutlet weak var collectionView: UICollectionView!
override func viewDidLoad() {
    super.viewDidLoad()
    setupCollectionViewDelegates()
    registerCells()
    view.backgroundColor = .red
}
}

extension RankingVC  : UICollectionViewDelegate, UICollectionViewDataSource {

    func setupCollectionViewDelegates() {
        collectionView.delegate = self
        collectionView.dataSource = self
    }

    func numberOfSections(in collectionView: UICollectionView) -> Int {
        return 1
    }

    func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
        return 10
    }

    func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {

        let cell = collectionView.dequeueReusableCell(withReuseIdentifier: CellIdentifier.rankingCVCell, for: indexPath) as! RankingCVCell
        return cell 
    }

    func registerCells() {
        RegisterCVCells.registerCell(withNibName: CellIdentifier.rankingCVCell, forCollectionView: collectionView)
    }
}

【问题讨论】:

  • collectionView(_:cellForItemAt:) 方法中,您是否应该将出队的单元格转换为您的自定义单元格类?
  • @Chris 你是对的,我忘了这样做,我认为这可以解决问题,但即使使用演员表,我仍然会遇到同样的错误
  • @Balaji 没有改变任何东西,它仍然崩溃并出现同样的错误。

标签: ios swift xcode uicollectionview uicollectionviewcell


【解决方案1】:

问题是我以编程方式将UICollectionViewCell 的高度设置为高于单元格本身。确保每个单元格的最小高度至少等于最短(就高度而言)单元格来解决这个问题。

【讨论】:

    猜你喜欢
    • 2014-01-30
    • 2017-02-25
    • 1970-01-01
    • 2021-02-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-12-26
    相关资源
    最近更新 更多