我正在从UICollectionView
中使用,我需要从中删除一些项目,但是当我像下面这样删除时:
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "CellItemSelectedLangShortTerm",
for: indexPath) as? HeadlineCollectionViewCellLangShortTerm
cell?.lblSelectedLang.text = displayedSelectedLangFilterShortTerm[indexPath.row].listLanguageFilter
cell?.btnDeleteLangSelected.tag = indexPath.row
cell?.btnDeleteLangSelected.addTarget(self, action: #selector(handleBtnDeleteLangSelected(sender:)), for: .touchUpInside)
return cell!
}
并且:
@objc func handleBtnDeleteLangSelected(sender: UIButton){
let selectedIndex = IndexPath(row: sender.tag, section: 0)
CViewSelectedLang.deleteItems(at: [selectedIndex])
}
让我出现以下错误:
The behavior of the UICollectionViewFlowLayout is not defined because:
2019-09-22 14:43:03.036600+0330 MyApp[7343:104811] the item height must be less than the height of the UICollectionView minus the section insets top and bottom values, minus the content insets top and bottom values.
2019-09-22 14:43:03.036944+0330 MyApp[7343:104811] The relevant UICollectionViewFlowLayout instance is <UICollectionViewFlowLayout: 0x7f9cd7c09630>, and it is attached to <UICollectionView: 0x7f9cd8156a00; frame = (8 10; 300 35); clipsToBounds = YES; autoresize = RM+BM; autoresizesSubviews = NO; gestureRecognizers = <NSArray: 0x6000002bb150>; layer = <CALayer: 0x600000cb0140>; contentOffset: {0, 0}; contentSize: {1210, 35}; adjustedContentInset: {0, 0, 0, 0}> collection view layout: <UICollectionViewFlowLayout: 0x7f9cd7c09630>.
2019-09-22 14:43:03.037075+0330 MyApp[7343:104811] Make a symbolic breakpoint at UICollectionViewFlowLayoutBreakForInvalidSizes to catch this in the debugger.