iphone - 我如何在 iPhone 的 tableview 中的特定行显示传入消息

标签 iphone ios tableview

我正在使用 xmpp 开发聊天应用程序。我可以发送和接收消息。我的联系人在此处的 TableView 中我的问题是当有来自在线用户的消息时我想在我的 TableView 中的在线用户行显示消息符号。当那个行被选中消息符号将消失。

我尝试了使用标签的休闲方式,但没有实现

-(UITableViewCell*)tableView:(UITableView *)tableView1 cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *cellIdentifier=@"cell";
    UITableViewCell *cell=[tableView1 dequeueReusableCellWithIdentifier:cellIdentifier];
    if(cell==nil)
    {
        cell=[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier];
    }

      XMPPUserCoreDataStorageObject *user1= [[self fetchedResultsController] objectAtIndexPath:indexPath];
      cell.textLabel.text = user1.displayName;


      UILabel *lblText = [[UILabel alloc] initWithFrame:CGRectMake(290,16,10,20)]; 
      lblText.textColor = [UIColor orangeColor];
      [cell addSubview:lblText];

      if([cell.textLabel.text isEqualToString:user1.jidStr])
      {
        lblText.text=@"g";
      }



}

谁能帮帮我。

提前致谢

最佳答案

传入消息存储在字典或数组中,然后重新加载 tableview 以显示最新到达的消息。

每次检索消息时都必须重新加载 TableView 。

关于iphone - 我如何在 iPhone 的 tableview 中的特定行显示传入消息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11517350/

相关文章:

ios - 自动布局网格按钮间距恒定

iphone - 如何将 SVG 导入/解析到 UIBezierpaths、NSBezierpaths、CGPaths 中?

javascript - 将 NSURLProtocol 与 ReactNative 结合使用

ios - 更新 TableView 导致滞后和警告

iphone - 将在Interface Builder中制作的自定义表格单元格与three20一起使用

ios - 在 iOS 8.1 中的 UIViewController viewDidLoad 之后查看层次结构不完整

iphone - 系统声音在 iPhone 模拟器中播放,但在 iPhone 上不播放

ios - UIImage -drawAtPoint : very slow for large images

ios - UITextField 验证

objective-c - 如何在我的自定义 TableviewCell 中访问 ImageView 而无需创建其导出