fee_S 2015-07-02 07:15 采纳率: 0%
浏览 1931

Swift coollectionView cell重用

func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell{

    let cell = self.collectionView.dequeueReusableCellWithReuseIdentifier("EntryCell", forIndexPath: indexPath) as! EntryCell

    let wdgt_icon = self.homesArr[indexPath.item].objectForKey("wdgt_icon") as? String


    //设置颜色
    let wdgt_color = self.homesArr[indexPath.item].objectForKey("wdgt_color") as? String
    cell.backgroundColor = color(wdgt_color!)
    //设置标题
    let titleLabel = UILabel(frame: CGRectMake(10, 0, 80, 30))
    titleLabel.textColor = UIColor.whiteColor()
    cell.contentView.addSubview(titleLabel)
    titleLabel.text = self.homesArr[indexPath.item].objectForKey("wdgt_title") as? String
    //设置icon
    let picLabel = UILabel(frame: CGRectMake(10, 40, 80, 40))
    picLabel.textColor = UIColor.whiteColor()
    cell.contentView.addSubview(picLabel)
    picLabel.text = self.iconDict[wdgt_icon!]
    let font:UIFont = UIFont(name: "FontAwesome", size: 40)!
    picLabel.font = font

    println(titleLabel.text)
    return cell
}
    上下滑动后,单元格上的图片和字会混乱,求解。。

图片说明

  • 写回答

1条回答

  • fee_S 2015-07-02 08:16
    关注

    问题解决了,需要自定义一下cell

    评论

报告相同问题?

悬赏问题

  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 对于相关问题的求解与代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料