diff --git a/Classes/LinphoneUI/UIChatBubblePhotoCell.m b/Classes/LinphoneUI/UIChatBubblePhotoCell.m index c9e4ed27c..75f1f5bfd 100644 --- a/Classes/LinphoneUI/UIChatBubblePhotoCell.m +++ b/Classes/LinphoneUI/UIChatBubblePhotoCell.m @@ -410,21 +410,25 @@ imgFrame.size = [UIChatBubbleTextCell getMediaMessageSizefromOriginalSize:[_finalImage.image size] withWidth:chatTableView.tableView.frame.size.width - 40]; imgFrame.origin.x = (bubbleFrame.size.width - imgFrame.size.width)/2; self.finalAssetView.frame = imgFrame; - - // Positioning text message - const char *utf8Text = linphone_chat_message_get_text_content(self.message); - - CGRect textFrame = self.messageText.frame; - textFrame.origin = CGPointMake(textFrame.origin.x, self.finalAssetView.frame.origin.y + self.finalAssetView.frame.size.height); - if (!utf8Text) { - textFrame.size.height = 0; - } else { - textFrame.size.height = bubbleFrame.size.height - textFrame.origin.x; - } - - self.messageText.frame = textFrame; - LOGD([NSString stringWithFormat:@"Text of the photoCell: %@, size of the text of the photoCell: %@", [self.messageText text], NSStringFromCGSize(textFrame.size)]); } + + // Positioning text message + const char *utf8Text = linphone_chat_message_get_text_content(self.message); + + CGRect textFrame = self.messageText.frame; + if (_finalImage.image) + textFrame.origin = CGPointMake(textFrame.origin.x, self.finalAssetView.frame.origin.y + self.finalAssetView.frame.size.height); + else + // When image hasn't be download + textFrame.origin = CGPointMake(textFrame.origin.x, 42); + if (!utf8Text) { + textFrame.size.height = 0; + } else { + textFrame.size.height = bubbleFrame.size.height - 90;//textFrame.origin.x; + } + + self.messageText.frame = textFrame; + LOGD([NSString stringWithFormat:@"Text of the photoCell: %@, size of the text of the photoCell: %@", [self.messageText text], NSStringFromCGSize(textFrame.size)]); } @end diff --git a/Classes/LinphoneUI/UIChatBubbleTextCell.m b/Classes/LinphoneUI/UIChatBubbleTextCell.m index 8e207f682..8d5bc27f1 100644 --- a/Classes/LinphoneUI/UIChatBubbleTextCell.m +++ b/Classes/LinphoneUI/UIChatBubbleTextCell.m @@ -416,9 +416,17 @@ static const CGFloat CELL_MESSAGE_Y_MARGIN = 52; // 44; CGSize fileSize = CGSizeMake(200, 80); size = [self getMediaMessageSizefromOriginalSize:fileSize withWidth:width]; } else { + CGSize textSize = CGSizeMake(0, 0); + if (![messageText isEqualToString:@"🗻"]) { + textSize = [self computeBoundingBox:messageText + size:CGSizeMake(width - CELL_MESSAGE_X_MARGIN - 4, CGFLOAT_MAX) + font:messageFont]; + size.height += textSize.height; + } + if (!localImage && !localVideo) { //We are loading the image - return CGSizeMake(CELL_MIN_WIDTH + CELL_MESSAGE_X_MARGIN, CELL_MIN_HEIGHT + CELL_MESSAGE_Y_MARGIN); + return CGSizeMake(CELL_MIN_WIDTH + CELL_MESSAGE_X_MARGIN, CELL_MIN_HEIGHT + CELL_MESSAGE_Y_MARGIN + textSize.height); } PHFetchResult *assets; if(localImage) @@ -435,13 +443,9 @@ static const CGFloat CELL_MESSAGE_Y_MARGIN = 52; // 44; size.height += 40; size.width -= CELL_MESSAGE_X_MARGIN; - if (![messageText isEqualToString:@"🗻"]) { - CGSize textSize = [self computeBoundingBox:messageText - size:CGSizeMake(width - CELL_MESSAGE_X_MARGIN - 4, CGFLOAT_MAX) - font:messageFont]; - size.height += textSize.height; - size.width = MAX(textSize.width, size.width); - } + // add size for message text + size.height += textSize.height; + size.width = MAX(textSize.width, size.width); } }