gpt4 book ai didi

ios - 日期未显示在 JSQMessagesViewcontroller 聊天页面中

转载 作者:行者123 更新时间:2023-11-29 12:00:31 26 4
gpt4 key购买 nike

messageForRow = [[JSQMessage alloc] initWithSenderId:[[DataArray objectAtIndex:indexPath.row] objectForKey:@"UserId"] senderDisplayName:[[DataArray objectAtIndex:indexPath.row] objectForKey:@"Name"] date:[NSDate distantPast] text: [[DataArray objectAtIndex:indexPath.row] objectForKey:@"Message"]];

enter image description here

最佳答案

您需要实现这些方法以使其可见

  - (NSAttributedString *)collectionView:(JSQMessagesCollectionView *)collectionView attributedTextForCellBottomLabelAtIndexPath:(NSIndexPath *)indexPath {
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:@"dd-MMM-yyyy"];//22-Nov-2012
NSString *formattedDateString = [dateFormatter stringFromDate:[[DataArray objectAtIndex:indexPath.row] date]];
return [[NSAttributedString alloc] initWithString:formattedDateString];
}

- (CGFloat)collectionView:(JSQMessagesCollectionView *)collectionView
layout:(JSQMessagesCollectionViewFlowLayout *)collectionViewLayout heightForCellBottomLabelAtIndexPath:(NSIndexPath *)indexPath {
return kJSQMessagesCollectionViewCellLabelHeightDefault;
}

关于ios - 日期未显示在 JSQMessagesViewcontroller 聊天页面中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37224316/

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