2017-02-24 114 views
0

我试图注册UICollectionViewCells数组的数组,但在循环我得到这个错误:不能调用与类型的参数lsit“注册”“(UICollectionViewCell,forCellWithResueidentifier:字符串)”无法注册UICollectionViewCells

My playground 
***let cell1 = UICollectionViewCell() 
let cell2 = UICollectionViewCell() 
let cells = [cell1, cell2] 
let collection = UICollectionView(frame: .zero, collectionViewLayout: UICollectionViewFlowLayout()) 
for cell in cells { 
    collection.register(cell, forCellWithReuseIdentifier: "hello") 
}*** 

Any ideas? 
Thanks in advance 

回答

0

你只需要注册一次,而不是单个细胞。

collection.register(UICollectionViewCell.self, forCellWithReuseIdentifier: "hello")