簡體   English   中英

reloadData 時 iPhone 6 中的應用程序崩潰

[英]Application crash in IPhone 6 while reloadData

我在側 UITableViewCell 中使用集合視圖,重新加載

func tableView(_ tableView: UITableView, willDisplay cell: UITableViewCell, forRowAt indexPath: IndexPath) {
        guard let _cell = cell as? BrandRow else { return }

        let _flow = columnLayout
        _flow.scrollDirection = .horizontal

        _cell.collectionView.collectionViewLayout = _flow
        _cell.collectionView.delegate = self
        _cell.collectionView.tag = indexPath.section
        _cell.collectionView.dataSource = self
        _cell.collectionView.showsVerticalScrollIndicator = false
        _cell.collectionView.showsHorizontalScrollIndicator = false
        _cell.collectionView.reloadData()

    }

在 iPhone 6 中,當電池被重復使用時,它會崩潰我的應用程序

_cell.collectionView.reloadData()

任何人都可以讓我知道我的代碼有什么問題嗎?

錯誤

-[UICollectionViewData validateLayoutInRect:]、/BuildRoot/Library/Caches/com.apple.xbs/Sources/UIKitCore/UIKit-3698.140/UICollectionViewData.m:447 中的斷言失敗

2021-01-28 17:10:08.921104+0500 Okayhai[630:48362] *** 由於未捕獲的異常“NSInternalInconsistencyException”而終止應用程序,原因:“UICollectionView 收到了具有不存在的索引路徑的單元格的布局屬性: <NSIndexPath: 0xec57a98e0a4dfaae> {length = 2, path = 0 - 4}'

試試這個:
下面_cell.collectionView.reloadData()

_cell.collectionView.collectionViewLayout.invalidateLayout()

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM