これは私のUIViewのサブビューであるUICollectionView有する単一のビューコントローラがXcodeの7.3.1、迅速2スイフト2、UICollectionViewが正しい識別子で正しくデキューしない
あります。コレクションビューには、識別子「NumberCell」を持つセルがあります。ここで
が私のViewController
func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell {
if let cell = collectionView.dequeueReusableCellWithReuseIdentifier("NumberCell", forIndexPath: indexPath) as? NumberCell {
let currentNumber = indexPath.row + 1
cell.configureCell(currentNumber)
cell.numberBtn.tag = currentNumber;
cell.numberBtn.addTarget(self, action: #selector(ViewController.playerClickedButton(_:)), forControlEvents: UIControlEvents.TouchUpInside)
return cell
} else {
return UICollectionViewCell()
}
}
の私cellForItemAtIndexPathですここで私は視覚的な問題ではなく、クラッシュを経験してい
func configureCell(cellNumber: Int) {
backNumberLbl.text = "\(cellNumber)"
frontNumberLbl.text = "\(cellNumber)"
self.tag = cellNumber
numberBtn.tag = cellNumber
}
(それは問題べきでないことを)私のセルの "configureCell" です。私がスクロールすると、新しいセルは画面からスクロールしたセルの特性を示しています。まだ壊れている識別子を変更しました。そして、私はそれを元に戻しました、まだ壊れました。私はcell.configureCell(currentNumber)の下にある他のコード行をコメントアウトしました。
私はすべてを調べており、これを把握することはできません。
ありがとうございましたStackOverflowコミュニティ!
'func registerClass(_:、forCellWithReuseIdentifier:)'を使って 'NumberCell'を' 'NumberCell" 'として登録しましたか? –
私はStoryBoardを、識別子が正確に "NumberCell"であるカスタムセルで使用しています – SZLSoft
以前のセルから表示されているセルは何ですか? – Abizern