Skip to content
This repository was archived by the owner on Aug 14, 2019. It is now read-only.

Commit ade4e7a

Browse files
committed
provide default init values for JSQMessagesCollectionViewLayoutAttributes to prevent assertion. fix #1338
1 parent 9c43534 commit ade4e7a

2 files changed

Lines changed: 12 additions & 1 deletion

File tree

JSQMessagesViewController/Layout/JSQMessagesCollectionViewFlowLayout.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,7 @@ - (NSArray *)layoutAttributesForElementsInRect:(CGRect)rect
319319

320320
- (UICollectionViewLayoutAttributes *)layoutAttributesForItemAtIndexPath:(NSIndexPath *)indexPath
321321
{
322-
JSQMessagesCollectionViewLayoutAttributes *customAttributes = (JSQMessagesCollectionViewLayoutAttributes *)[super layoutAttributesForItemAtIndexPath:indexPath];
322+
JSQMessagesCollectionViewLayoutAttributes *customAttributes = (JSQMessagesCollectionViewLayoutAttributes *)[[super layoutAttributesForItemAtIndexPath:indexPath] copy];
323323

324324
if (customAttributes.representedElementCategory == UICollectionElementCategoryCell) {
325325
[self jsq_configureMessageCellLayoutAttributes:customAttributes];

JSQMessagesViewController/Layout/JSQMessagesCollectionViewLayoutAttributes.m

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,17 @@
2020

2121
@implementation JSQMessagesCollectionViewLayoutAttributes
2222

23+
#pragma mark - Init
24+
25+
- (instancetype)init {
26+
self = [super init];
27+
if (self) {
28+
_messageBubbleFont = [UIFont preferredFontForTextStyle:UIFontTextStyleBody];
29+
_messageBubbleContainerViewWidth = 320.0f;
30+
}
31+
return self;
32+
}
33+
2334
#pragma mark - Setters
2435

2536
- (void)setMessageBubbleFont:(UIFont *)messageBubbleFont

0 commit comments

Comments
 (0)