gpt4 book ai didi

ios - 如何在消息气泡中添加时间标签?

转载 作者:可可西里 更新时间:2023-10-31 23:44:25 26 4
gpt4 key购买 nike

我在我的应用程序中使用 JSQMessageController,现在我想在我的气泡中添加时间标签。

here

我在我的目录中搜索,但没有找到图像 Assets 文件夹。但是当我在这里输入图像/ Assets 名称时:

我正在尝试这个:

override func collectionView(collectionView: JSQMessagesCollectionView!, attributedTextForCellBottomLabelAtIndexPath indexPath: NSIndexPath!) -> NSAttributedString! {
let message: JSQMessage = self.messages[indexPath.item] as! JSQMessage
return JSQMessagesTimestampFormatter.sharedFormatter().attributedTimestampForDate(message.date)
}

但这不是我想要的。我想将此标签添加到消息气泡中。

任何建议,即使是用 Objective-C 编写的?

最佳答案

请试试这个。它对我有用。

- (UICollectionViewCell *)collectionView:(JSQMessagesCollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{

JSQMessagesCollectionViewCell *cell = (JSQMessagesCollectionViewCell *)[super collectionView:collectionView cellForItemAtIndexPath:indexPath];

JSQMessage *message = [jsqmessages objectAtIndex:indexPath.item];
//cell.messageBubbleTopLabel.text = message.senderDisplayName;
NSDateFormatter *dateFormat = [[NSDateFormatter alloc]init];
[dateFormat setDateFormat:@"MMM dd, yyyy"];
NSString *strDate = [dateFormat stringFromDate:message.date];
cell.cellTopLabel.text = strDate;
return cell;
}

关于ios - 如何在消息气泡中添加时间标签?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33911553/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com