我有一个UICollectionView,我在其中使用自定义单元格。我正在viewDidLoad中注册单元格:
DisplayMetrics metrics = new DisplayMetrics();
WindowManager windowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
windowManager.getDefaultDisplay().getMetrics(metrics);
并在cellForItemAt中设置它们:
self.collectionView.register(UINib(nibName: "IntroCell", bundle: nil), forCellWithReuseIdentifier: "IntroCell")
IntroCell看起来像这样:
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
let cell:IntroCell = collectionView.dequeueReusableCell(withReuseIdentifier: reuseIdentifier, for: indexPath) as! IntroCell
cell.refresh(cell: self.introScreens[indexPath.row])
return cell
}
但每当我跑步时,我都会收到此错误:
class IntroCell : UICollectionViewCell{
@IBOutlet weak var subtitle: UILabel!
@IBOutlet weak var title: UILabel!
@IBOutlet weak var image: UIImageView!
public func refresh(cell : IntroCellModel) {
self.image.image = cell.image
self.title.text = cell.title
self.subtitle.text = cell.subtitle
}
}