func numberOfSectionsInCollectionView(collectionView: UICollectionView) -> Int {
return 2
}
func collectionView(collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
if section == 0{
if chiefModel?.data?.banner != nil {
return 1
}
}else if section == 1{
let number = chiefModel?.data?.chefList?.count
if number != nil {
return number!
}
}
return 0
}
func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell {
if indexPath.section == 0{
let cell = HPChiefBannerCell.createChiefBannerCellForCollectionView(collectionView, atIndexPath: indexPath, withChiefModel: chiefModel!)
return cell
} else if indexPath.section == 1{
let cell = collectionView.dequeueReusableCellWithReuseIdentifier("chiefCellId", forIndexPath: indexPath) as! HPChiefCollectionViewCell
Util.decorateView(cell)
let models = chiefModel?.data?.chefList
let model = models![indexPath.item]
let urlString = model.imageurl
let url = NSURL(string: urlString!)
cell.imageView.kf_setImageWithURL(url, placeholderImage: UIImage(named: "sdefaultImage"), optionsInfo: nil, progressBlock: nil, completionHandler: nil)
cell.nameLabel.text = model.name
cell.orderLabel.text = "\((model.orderedCount)!)人已预订 | \((model.likeCount)!)人喜欢"
cell.introduceLabel.text = model.introduce
return cell
}
return UICollectionViewCell()
}
最后编辑于 :
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。