đây là đoạn code để làm điều này .. Tôi đã thử phương pháp này ... Đối với tế bào động và tế bào tĩnh ...
func numberOfSectionsInCollectionView(collectionView: UICollectionView) -> Int {
return 2
}
// Retuens the number of sections in collectionview
func collectionView(collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int
{
if section == 0 {
return data.count
}else if section == 1{
return 1
}else {
return 0
}
}
// Data get's filled into UICollectionView
func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell
{
var cell : CollectionCell!// important step...
if indexPath.section == 0 {
cell = collectionView.dequeueReusableCellWithReuseIdentifier("collectionViewCell", forIndexPath: indexPath) as! CollectionCell
//do something inside this
}
else if indexPath.section == 1 {
cell = collectionView.dequeueReusableCellWithReuseIdentifier("Cell", forIndexPath: indexPath) as! CollectionCell
//here the static cell...
}
return cell
}
Nguồn
2016-06-14 04:30:55
đâu mã của bạn? – Raptor
để bạn muốn có cả hai: ô tĩnh và động? Nếu đây là những gì bạn muốn .. tôi không thực sự nghĩ rằng điều này là có thể –
@BogdanSomlea Yeah trong cùng CollectionView để có một tế bào động và tĩnh tế bào, hai tế bào tạo ra trên IB trên cùng một collectionview một trong số họ sẽ được lấp đầy với một mảng sẽ ở lại tĩnh nó sẽ không có bất kỳ dữ liệu nhập nhưng tôi muốn nó được thêm vào cuối cùng sau khi tất cả các tế bào động đầy từ mảng. điều đó có thể không ? – Durim