修改了公屏的保存最大的数量
This commit is contained in:
@@ -18,6 +18,8 @@ static CGFloat kRoomMessageDefalutFont = 12;
|
||||
static CGFloat kRoomMessageTextSpaceHeight = 10;
|
||||
|
||||
static CGFloat kRoomMessageBubbleCornerRadius = 7;
|
||||
///公屏保存的最大数
|
||||
static CGFloat kRoomMessageMaxLength = 1000;
|
||||
|
||||
|
||||
#endif /* XPRoomMessageConstant_h */
|
||||
|
@@ -124,12 +124,20 @@
|
||||
if (self.tempArray.count < 1) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (self.datasource.count > kRoomMessageMaxLength) {
|
||||
NSIndexSet *set = [NSIndexSet indexSetWithIndexesInRange:NSMakeRange(0, kRoomMessageMaxLength/2)];
|
||||
NSArray *needRemoveMsgArray = [self.datasource objectsAtIndexes:set];
|
||||
[self.datasource removeObjectsInArray:needRemoveMsgArray];
|
||||
}
|
||||
|
||||
// 执行插入
|
||||
NSMutableArray *indexPaths = [NSMutableArray array];
|
||||
for (XPRoomMessageDisplayModel *item in self.tempArray) {
|
||||
[self.datasource addObject:item];
|
||||
[indexPaths addObject:[NSIndexPath indexPathForRow:self.datasource.count - 1 inSection:0]];
|
||||
}
|
||||
NSLog(@"消息的总数%ld", self.datasource.count);
|
||||
[self.messageTableView reloadData];
|
||||
[self.tempArray removeAllObjects];
|
||||
|
||||
|
Reference in New Issue
Block a user