0
私は私の
のUIViewControllerでUICollectionViewCell
変更項目は、私はこのように宣言UICollectionViewCell
内の特定の項目のサイズを変更しようとしている
の内側サイズ:
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: Storyboard.CellIdentifier, for: indexPath) as! NameCollectionViewCell
if(retreivedEvents == nil) {
// print("data not received yet...")
return cell
} else {
// print("new data given")
cell.anEvent = self.retreivedEvents![indexPath.row]
cell.setNeedsLayout()
return cell
}
}
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAtIndexPath indexPath: IndexPath) -> CGSize {
let cell2 = collectionView.dequeueReusableCell(withReuseIdentifier: Storyboard.CellIdentifier, for: indexPath) as! NameCollectionViewCell
let screenHeigh = UIScreen.main.bounds.size.height
cell2.frame.size.height = cellSize * 0.8
cell2.descriptionTextView.frame.size.height += 50
cell2.theImageView.frame.size.height = cellSize * 0.8
let layout = collectionView.collectionViewLayout as! UICollectionViewFlowLayout
layout.sectionInset = UIEdgeInsets(top: 0, left: 10, bottom: 0, right: 10)
return CGSize(width: self.collectionView.frame.width,height:cell2.frame.size.height)
}
問題: たびにIそれを実行すると、コンソールが表示されます
tyのキャッチされない例外で終了pe NSException
私はエラーが何であるか分かりません。
もっと情報を共有できますか?アプリがクラッシュする場所(コード行) –
@JimmyJamesこんにちは、はい。 AppDelegate.swiftの中にあります。 ***キャッチされていない例外 'NSRangeException'、理由: '*** - [__ NSArrayM objectAtIndex:]:境界1を越えるインデックス1' – WoShiNiBaBa
デバッグするための例外ブレークポイントを配置 –