 
     func collectionView(collectionView: UICollectionView!, layout collectionViewLayout: UICollectionViewLayout!, sizeForItemAtIndexPath indexPath: NSIndexPath!) -> CGSize {
 
-        let message = messages.objectAtIndex(UInt(currentDisplayedMessagesRange.location + indexPath.item)) as! Message
+        let message = messages.objectAtIndex(UInt(displayedMessagesRange.location + indexPath.item)) as! Message
 
         return CGSizeMake(collectionViewWidth, heightOfMessage(message))
     }

        return messagesInConversation(self.conversation)
        }()

    var lastDisplayedMessagesRange = NSRange()
    var currentDisplayedMessagesRange = NSRange()

    // 上一次更新 UI 时的消息数
    var lastTimeMessagesCount: UInt = 0

    }

    func collectionView(collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
        return displayedMessagesRange.length
    }

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

        let message = messages.objectAtIndex(UInt(displayedMessagesRange.location + indexPath.item)) as! Message

        if message.mediaType == MessageMediaType.SectionDate.rawValue {
            let cell = collectionView.dequeueReusableCellWithReuseIdentifier(chatSectionDateCellIdentifier, forIndexPath: indexPath) as! ChatSectionDateCell
