如何在不刷新主视图的情况下更新UILabel?

时间:2016-06-15 09:42:27

标签: ios iphone xcode swift uicollectionview

我正在尝试使用集合视图委托来更新主视图上的UILabel。但是,一旦标签更新,它就会更新整个视图,这意味着它会返回到屏幕的开头 - 动画之前。是否可以只更新monthLabel而不是更新所有内容?

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


    let cell2 = CollectionView.dequeueReusableCellWithReuseIdentifier("CollectionCell", forIndexPath: indexPath) as! BookingDateCollectionCellClass

    let later = getDate(indexPath.row + 5).day
    print(later)


    let date: String = String(later)
    print(date)
    cell2.dateLabel.text = date

    let day = getDateData(indexPath.row + 5).dayOfWeek()
    print(day)
    cell2.dayLabel.text = dayShortFromNumber(day!)


    self.monthlabel.text = monthFromNumber(getDate(indexPath.row + 5).month)

    return cell2

}

这是开始动画前的屏幕: App with CollectionView before animation 这是开始动画后的屏幕: App with CollectionView after animation

0 个答案:

没有答案