2015-12-10 34 views
0

我正在嘗試向所有外發聊天氣泡添加已發送/未發送狀態消息。爲此,我從heightForCellBottomLabelAtIndexPath方法重新調用40。無法在JSQMessagesViewController中看到底部標籤的文本

同樣來自於JavasTextForCellBottomLabelAtIndexPath方法我返回一個屬性字符串。例如,

  1. NSMutableAttributedString *hogan = [[NSMutableAttributedString alloc] initWithString:@"Presenting the great... Hulk Hogan!"];

  2. [hogan addAttribute:NSFontAttributeName value:[UIFont
    systemFontOfSize:20.0] range:NSMakeRange(24, 8)];

  3. [hogan addAttribute:NSForegroundColorAttributeName value:[UIColor blackColor] range:NSMakeRange(10, 10)];

我的細胞之間的這個空間現在已經後增加至40,但我看不到任何文本我回歸爲屬性字符串。此外,如果我繼續增加40的值,單元格之間的空間不斷增加,但單元格標籤文本不可見。

請告訴我我做錯了什麼。

回答

0

正如您所說,您正在使用的是JavasTextForCellBottomLabelAtIndexPath,但文本不可見。請你按照下面的方式,希望它有幫助。

第1步:轉到cellForRowAtIndextPath 第2步:cell.bottomLabel.text = @「介​​紹偉大的...綠巨人霍根!」; 從webservice獲取狀態值後,重新加載集合視圖。那時更新的谷值將會顯示。

如果有任何問題,請讓我知道。

0

請確保在代碼中添加了以下方法。

override func collectionView(collectionView: JSQMessagesCollectionView!, layout collectionViewLayout: JSQMessagesCollectionViewFlowLayout!, heightForCellBottomLabelAtIndexPath indexPath: NSIndexPath!) -> CGFloat { 
     return 30.0; 
    }