2012-07-17 65 views
0

我正在開發聊天應用程序使用xmpp.I可以發送和接收message.My的聯繫人在tableview這裏我的問題是當有消息從在線用戶,然後我想在我的tableview中的在線用戶行顯示消息符號。當該行被選中時,消息符號將消失。我怎麼能顯示傳入消息在iPhone的tableview中的特定行

我試着用標籤休耕的方式,但並沒有達到

-(UITableViewCell*)tableView:(UITableView *)tableView1 cellForRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
    static NSString *[email protected]"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]) 
     { 
     [email protected]"g"; 
     } 



} 

任何一個可以幫助我。

由於事先

回答

1

在字典傳入消息存儲或陣列然後刷新爲顯示其到達最新消息的tableview。

您必須在每次檢索消息時重新載入表視圖。

0

您的標籤應該添加在cell.contentView。表格視圖單元格有許多子視圖,並且爲您指定使用的是contentView

假設您爲了我們的利益簡化了代碼,但爲了以防萬一,您必須在消息進入後(大概在您的Core Data對象中)存儲消息並致電[UITableView reloadRowsAtIndexPaths:withRowAnimation:]

1

使用下面的表格視圖方法將新行添加到表..

-insertRowsAtIndexPaths:withRowAnimation: 

希望它可以幫助....

0

應當刷新其存儲在表的數據,那麼NSArray的[ tableView reloadData];例如,NSArray的計數爲15,並且您收到一條新消息,則應刷新NSArray以包含16個對象。

相關問題