UICollectionView's cell registerClass in Swift

前端 未结 4 694
既然无缘
既然无缘 2020-12-15 02:09

Right now I\'m using NSClassFromString, but is there a better way to get an AnyClass! from a class in Swift? I am trying to pass the reference to m

4条回答
  •  抹茶落季
    2020-12-15 03:03

    In Swift 3:

    self.collectionView.register(CustomCollectionViewCell.self, forCellWithReuseIdentifier: "CustomCollectionViewCellReuseIdentifier")
    

提交回复
热议问题