@@ -79,6 +79,7 @@ - (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reus
79
79
[self .mediaView setBackgroundView: nil ];
80
80
[self .mediaView setBackgroundColor: [UIColor clearColor ]];
81
81
[self .mediaView registerClass: [MessageMediaItemCCell class ] forCellWithReuseIdentifier: kCCellIdentifier_MessageMediaItem ];
82
+ [self .mediaView registerClass: [MessageMediaItemCCell class ] forCellWithReuseIdentifier: kCCellIdentifier_MessageMediaItem_Single ];
82
83
self.mediaView .dataSource = self;
83
84
self.mediaView .delegate = self;
84
85
[_bgImgView addSubview: self .mediaView];
@@ -173,7 +174,8 @@ - (void)setCurPriMsg:(PrivateMessage *)curPriMsg andPrePriMsg:(PrivateMessage *)
173
174
// 有图片
174
175
[_contentLabel setY: 2 *kMessageCell_PadingHeight + mediaViewHeight];
175
176
176
- bgImgViewSize = CGSizeMake (kMessageCell_ContentWidth +2 *kMessageCell_PadingWidth ,
177
+ CGFloat contentWidth = [_curPriMsg isSingleBigMonkey ]? [MessageMediaItemCCell singleCcellSize ].width : kMessageCell_ContentWidth ;
178
+ bgImgViewSize = CGSizeMake (contentWidth +2 *kMessageCell_PadingWidth ,
177
179
mediaViewHeight +textSize.height + kMessageCell_PadingHeight *(_curPriMsg.content .length > 0 ? 3 :2 ));
178
180
} else if (curPriMsg.file || curPriMsg.voiceMedia ) {
179
181
bgImgViewSize = CGSizeMake (kMessageCell_ContentWidth , 40 );
@@ -221,10 +223,6 @@ - (void)setCurPriMsg:(PrivateMessage *)curPriMsg andPrePriMsg:(PrivateMessage *)
221
223
bgImg = [bgImg resizableImageWithCapInsets: UIEdgeInsetsMake (18 , 30 , bgImg.size.height - 19 , bgImg.size.width - 31 )];
222
224
_contentLabel.textColor = [UIColor blackColor ];
223
225
_bgImgView.frame = bgImgViewFrame;
224
- if (_voiceView) {
225
- bgImg = nil ; // 使用bubbleView的背景
226
- _voiceView.type = BubbleTypeLeft;
227
- }
228
226
}else {
229
227
// 这是自己发的
230
228
bgImgViewFrame = CGRectMake ((kScreen_Width - kPaddingLeftWidth - kMessageCell_UserIconWith ) -bgImgViewSize.width , curBottomY +kMessageCell_PadingHeight , bgImgViewSize.width , bgImgViewSize.height );
@@ -233,10 +231,10 @@ - (void)setCurPriMsg:(PrivateMessage *)curPriMsg andPrePriMsg:(PrivateMessage *)
233
231
bgImg = [bgImg resizableImageWithCapInsets: UIEdgeInsetsMake (18 , 30 , bgImg.size.height - 19 , bgImg.size.width - 31 )];
234
232
_contentLabel.textColor = [UIColor blackColor ];
235
233
_bgImgView.frame = bgImgViewFrame;
236
- if (_voiceView) {
237
- bgImg = nil ; // 使用bubbleView的背景
238
- _voiceView. type = BubbleTypeRight;
239
- }
234
+ }
235
+ if (_voiceView) {
236
+ bgImg = nil ; // 使用bubbleView的背景
237
+ _voiceView. type = BubbleTypeRight;
240
238
}
241
239
242
240
__weak typeof (self) weakSelf = self;
@@ -248,7 +246,8 @@ - (void)setCurPriMsg:(PrivateMessage *)curPriMsg andPrePriMsg:(PrivateMessage *)
248
246
[_bgImgView setImage: bgImg];
249
247
250
248
if (_mediaView) {
251
- [_mediaView setHeight: mediaViewHeight];
249
+ CGFloat contentWidth = [_curPriMsg isSingleBigMonkey ]? [MessageMediaItemCCell singleCcellSize ].width : kMessageCell_ContentWidth ;
250
+ [_mediaView setSize: CGSizeMake (contentWidth, mediaViewHeight)];
252
251
[_mediaView reloadData ];
253
252
}
254
253
@@ -336,10 +335,14 @@ + (CGFloat)mediaViewHeightWithObj:(PrivateMessage *)curPriMsg{
336
335
if (curPriMsg.nextImg ) {
337
336
mediaViewHeight += [MessageMediaItemCCell ccellSizeWithObj: curPriMsg.nextImg].height ;
338
337
}else {
339
- for (HtmlMediaItem *curItem in curPriMsg.htmlMedia .imageItems ) {
340
- mediaViewHeight += [MessageMediaItemCCell ccellSizeWithObj: curItem].height +kMessageCell_PadingHeight ;
338
+ if ([curPriMsg isSingleBigMonkey ]) {
339
+ mediaViewHeight += [MessageMediaItemCCell singleCcellSize ].height ;
340
+ }else {
341
+ for (HtmlMediaItem *curItem in curPriMsg.htmlMedia .imageItems ) {
342
+ mediaViewHeight += [MessageMediaItemCCell ccellSizeWithObj: curItem].height +kMessageCell_PadingHeight ;
343
+ }
344
+ mediaViewHeight -= kMessageCell_PadingHeight ;
341
345
}
342
- mediaViewHeight -= kMessageCell_PadingHeight ;
343
346
}
344
347
}
345
348
return mediaViewHeight;
@@ -356,10 +359,8 @@ - (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSe
356
359
357
360
// The cell that is returned must be retrieved from a call to -dequeueReusableCellWithReuseIdentifier:forIndexPath:
358
361
- (UICollectionViewCell *)collectionView : (UICollectionView *)collectionView cellForItemAtIndexPath : (NSIndexPath *)indexPath {
359
- MessageMediaItemCCell *ccell = [collectionView dequeueReusableCellWithReuseIdentifier: kCCellIdentifier_MessageMediaItem forIndexPath: indexPath];
362
+ MessageMediaItemCCell *ccell = [collectionView dequeueReusableCellWithReuseIdentifier: [_curPriMsg isSingleBigMonkey ]? kCCellIdentifier_MessageMediaItem_Single: kCCellIdentifier_MessageMediaItem forIndexPath: indexPath];
360
363
ccell.refreshMessageMediaCCellBlock = self.refreshMessageMediaCCellBlock ;
361
-
362
- ccell.curPriMsg = _curPriMsg;
363
364
if (_curPriMsg.nextImg ) {
364
365
ccell.curObj = _curPriMsg.nextImg ;
365
366
}else {
@@ -370,14 +371,17 @@ - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cell
370
371
return ccell;
371
372
}
372
373
373
-
374
374
- (CGSize )collectionView : (UICollectionView *)collectionView layout : (UICollectionViewLayout*)collectionViewLayout sizeForItemAtIndexPath : (NSIndexPath *)indexPath {
375
375
CGSize itemSize = CGSizeZero ;
376
376
if (_curPriMsg.nextImg ) {
377
377
itemSize = [MessageMediaItemCCell ccellSizeWithObj: _curPriMsg.nextImg];
378
378
}else {
379
- HtmlMediaItem *curItem = [_curPriMsg.htmlMedia.imageItems objectAtIndex: indexPath.row];
380
- itemSize = [MessageMediaItemCCell ccellSizeWithObj: curItem];
379
+ if ([_curPriMsg isSingleBigMonkey ]) {
380
+ itemSize = [MessageMediaItemCCell singleCcellSize ];
381
+ }else {
382
+ HtmlMediaItem *curItem = [_curPriMsg.htmlMedia.imageItems objectAtIndex: indexPath.row];
383
+ itemSize = [MessageMediaItemCCell ccellSizeWithObj: curItem];
384
+ }
381
385
}
382
386
return itemSize;
383
387
}
0 commit comments