![enter image description here][2]I have a table view,in which I am using my custom cell that contains user's profile picture,status label, time stamp label, username label, no of comments label and a comment button.
When no of comments i.e"4 comments" is tapped, I ha ve to show comments in the corresponding cell along with username, user profile picture etc below the original post.
How do I dynamically add these objects into cell when the app is running? or there is some else solution please tell. table for 2 posts is shown in right of image. Tapping no of comments left of the image should be shown.
Here is the code for table cell:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"MyCell";
TableCell *cell = (TableCell *) [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
NSArray* topLevelObjects = [[NSBundle mainBundle] loadNibNamed:@"TableCell" owner:self options:nil];
for (id currentObject in topLevelObjects) {
if ([currentObject isKindOfClass:[UITableViewCell class]]) {
cell = (TableCell *)currentObject;
break;
}
}
}
// Configure the cell.
User *user = [postTableData objectAtIndex:indexPath.row];
NSLog(@"pic:%@",user.profilePictureURL);
cell.profilePicture.image = [UIImage imageNamed:@"avatar.png"];
cell.profilePicture.layer.cornerRadius = cell.profilePicture.frame.size.height /2;
cell.profilePicture.layer.masksToBounds = YES;
cell.profilePicture.layer.borderWidth = 0;
cell.userName.text = user.name;
cell.status.text = user.status;
cell.dateForStatus.text = user.datePosted;
[cell.countComments setTitle:user.countOfComments forState:UIControlStateNormal];
cell.selectionStyle = UITableViewCellSelectionStyleNone;
[cell.contentView.layer setBorderWidth:6.0f];
[cell.contentView.layer setBorderColor:[[UIColor alloc] initWithRed:233/255.0 green:236/255.0 blue:233/255.0 alpha:1.0].CGColor];
cell.commentButton.tag=indexPath.row;
[cell.commentButton addTarget:self action:@selector(commentButtonPressAction:) forControlEvents:UIControlEventTouchUpInside];
return cell;
![enter image description here][3]}
heightForRowAtIndexPath: