iphone - 带有头像图像和带有时间戳的头像名称的气泡消息
<p><p>我必须使用 <code>senders AVATAR</code> 和 <code>Sender's name with time-stamps</code> 来实现气泡消息,与下面的屏幕截图相同。 </p>
<p>我已经成功实现了<code>简单的气泡类型消息</code>。现在我有一些很好的 Git-hub 项目可以提供给我,但我需要的是不同的东西。</p>
<p>我什至用过<a href="https://www.cocoacontrols.com/controls/acanichat" rel="noreferrer noopener nofollow">acanichat</a>但没有运气。</p>
<p>所以任何人都可以建议我很好的教程吗?或者任何人已经用这个 <a href="https://github.com/AlexBarinov/UIBubbleTableView" rel="noreferrer noopener nofollow">Git-hub Library</a>或与任何其他图书馆?</p>
<p>我想要一个带有<code>发件人头像</code>和<code>带有时间戳的发件人姓名</code>的气泡消息,请看下图。</p>
<p> <img src="/image/xiHDG.jpg" alt="enter image description here"/> </p>
<p>您的建议很重要。</p></p>
<br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
<p><p>您为什么不创建自己的聊天表?您只需要创建两个自定义单元,并在 XIB 文件的帮助下,您可以提供任何您想要的外观。</p>
<p>使用下面的微分器和条件。</p>
<pre><code>- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier1 = @"Cell1";
static NSString *CellIdentifier2 = @"Cell2";
CGSize boundingSize = CGSizeMake(messageWidth-20, 10000000);
CGSize itemTextSize =
constrainedToSize:boundingSize
lineBreakMode:NSLineBreakByWordWrapping];
float textHeight = itemTextSize.height+7;
if (messageType isEqualToString:@"textByme"]) {
CustomCell1*cell = (CustomCell1 *);
if (cell == nil) {
NSArray *topLevelObjects = [ loadNibNamed:@"CustomCell1" owner:self options:nil];
cell = ;
}
UIImageView *bubbleImage=[ initWithImage:[ stretchableImageWithLeftCapWidth:15 topCapHeight:15]];
bubbleImage.tag=55;
;
;
UITextView *messageTextview=[initWithFrame:CGRectMake(250-itemTextSize.width,0,itemTextSize.width+15, textHeight)];
;
messageTextview.editable=NO;
messageTextview.text = messageText;
messageTextview.dataDetectorTypes=UIDataDetectorTypeAll;
messageTextview.textAlignment=NSTextAlignmentJustified;
messageTextview.font=;
messageTextview.backgroundColor=;
messageTextview.tag=indexPath.row;
cell.Avatar_Image.image=;
cell.time_Label.text=data.messageTime;
cell.selectionStyle=UITableViewCellSelectionStyleNone;
messageTextview.scrollEnabled=NO;
return cell;
}
else{
CustomCell2*cell = (CustomCell2 *);
if (cell == nil) {
NSArray *topLevelObjects = [ loadNibNamed:@"CustomCell2" owner:self options:nil];
cell = ;
}
UIImageView *bubbleImage=[ initWithImage:[ stretchableImageWithLeftCapWidth:15 topCapHeight:15]];
;
;
bubbleImage.tag=56;
UITextView *messageTextview=[initWithFrame:CGRectMake(50,0,itemTextSize.width+15, textHeight)];
;
messageTextview.editable=NO;
messageTextview.text = messageText;
messageTextview.dataDetectorTypes=UIDataDetectorTypeAll;
messageTextview.textAlignment=NSTextAlignmentJustified;
messageTextview.backgroundColor=;
messageTextview.font=;
messageTextview.scrollEnabled=NO;
messageTextview.tag=indexPath.row;
cell.Avatar_Image.image=;
cell.time_Label.text=feed_data.messageTime;
cell.selectionStyle=UITableViewCellSelectionStyleNone;
return cell;
}
}
</code></pre>
<p>高度:</p>
<pre><code>- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
float cellHeight;
// text
NSString *messageText = @"Your text";
//
CGSize boundingSize = CGSizeMake(messageWidth-20, 10000000);
CGSize itemTextSize =
constrainedToSize:boundingSize
lineBreakMode:NSLineBreakByWordWrapping];
// plain text
cellHeight = itemTextSize.height;
if (cellHeight<25) {
cellHeight=25;
}
return cellHeight+30;
}
</code></pre></p>
<p style="font-size: 20px;">关于iphone - 带有头像图像和带有时间戳的头像名称的气泡消息,我们在Stack Overflow上找到一个类似的问题:
<a href="https://stackoverflow.com/questions/19269564/" rel="noreferrer noopener nofollow" style="color: red;">
https://stackoverflow.com/questions/19269564/
</a>
</p>
页:
[1]