2016-04-24 14 views
0

現在表示されていないが以前にロードされた別のTableViewControllerのtableViewにUITableViewCellを追加している奇妙な問題が発生しています。 問題は、セルがのtableViewに追加されますが、私はそのビューコントローラに移動後、セルの内容が空白であるということである。UITableViewCellの内容他のView Controllerからセルが追加されたときに表示されない

enter image description here

これは、セルが追加される方法です。 enter image description here

セルcontentViewのtableViewの

CellForRowAtIndexPathは見えないまで表示されます。

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { 

      LYRConversation *conversation = [_dataSource objectAtIndex:indexPath.row]; 

      ConversationListCell *cell = (ConversationListCell *)[tableView dequeueReusableCellWithIdentifier:CELL_REUSE_ID forIndexPath:indexPath]; 

      [self configureCell:cell atIndexPath:indexPath conversation:conversation]; 

      return cell; 

} 

-(void)configureCell:(ConversationListCell *)conversationCell atIndexPath:(NSIndexPath *)indexPath conversation:(LYRConversation *)conversation 
{ 
    [conversationCell updateAvatarWithUrl:[NSURL URLWithString:[self avatarStringUrlForConversation:conversation]]]; 
    [conversationCell updateTitle:[self titleForConversation:conversation]]; 
    [conversationCell updateUnreadMessageIndicator:conversation]; 
    NSArray *otherParticipants = [[PersistentCache sharedCache] cachedUsersForUserIDs:conversation.participants]; 
    conversationCell.preview.text = [((PFUser *)otherParticipants.lastObject) objectForKey:@"jobTitle"]; 
    [UIView updateStatusIndicatorOfConversation:otherParticipants statusIndicator:conversationCell.status]; 
} 


-(void)updateAvatarWithUrl:(NSURL *)avatarUrl 
{ 
    if (avatarUrl != nil) { 
     downloadImageThenSetForImageView(self.avatar, avatarUrl); 
    } 
} 

-(void)updateTitle:(NSString *)title 
{ 
    self.title.text = title; 
} 

-(void)updateUnreadMessageIndicator:(LYRConversation *)conversation 
{ 
    if (conversation.lastMessage.isUnread) { 
     [_unreadMessageIndicator setImage:[ConversationListCell unreadBlue]]; 
    } 
    else { 
     [_unreadMessageIndicator setImage:[ConversationListCell unreadGray]]; 
    } 
} 

+(void)updateStatusIndicatorOfConversation:(NSArray<PFUser *> *)users statusIndicator:(UIView *)view 
{ 
    int statusValue = ((NSNumber *)[users.firstObject objectForKey:@"status"]).intValue; 
    if (statusValue == 1) { 
     view.backgroundColor = [UIColor PNGInOffice]; 
    } 
    else if(statusValue == 2){ 
     view.backgroundColor = [UIColor PNGBusy]; 
    } 
    else if(statusValue == 3){ 
     view.backgroundColor = [UIColor PNGAway]; 
    } 
} 

このビューコントローラは、ストーリーボードの自動レイアウトを使用してレイアウトされています。ありがとうございました!

答えて

0

データをデータソースに追加した後、テーブルビューを更新してみようとしています。

+0

私はそれを試みましたが、それでもまだ空白が表示されます – Midas

0

この行を追加する必要があります。追加しようとしてみます。 [tableView reloadData];

+0

それは動作しませんでした:(最上部のセルはまだ空白になります) – Midas

+0

私は間違いなくあなたを助けます。 – Abhimanyu

+0

ソースファイルはかなり長いですが、私に共有したい特定のコードがあるのでしょうか、あるいは両方のコントローラ実装ファイルを表示していますか? – Midas

関連する問題