views:

114

answers:

2

I have 3 tables called radio, song, and artist controlled by favorite. Now I want to display different text for each table when there is nothing inside the table. But I want the text to be removed when there is something inside the table. I could display the text, by adding label into it.

if ([mainDataCenter.favoriteArtistArray count] == 0)
 {
  [label setTextColor:[UIColor whiteColor]];
  [label setText:@"AUCUN FAVORI DE FICHE ARTISTE"];
 }
 else
 {
  [label setHidden:YES];
 }

but after the text is hidden in one table ( meaning there is something added only to that particular table) but the other texts in other tables also disappeared.

- (void)tableView:(UITableView*)tv commitEditingStyle:(UITableViewCellEditingStyle)editingStyle 
forRowAtIndexPath:(NSIndexPath*)indexPath 
{
    // If row is deleted, remove it from the list.
    if (UITableViewCellEditingStyleDelete == editingStyle) 
    {
     WebRadio *aRadio = [mainDataCenter.favoriteWebRadioArray objectAtIndex:indexPath.row];
        [mainDataCenter removeWebRadioFromFavorite:aRadio];
        // Animate the deletion from the table.
        [tv deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];    
    }

this is the code where I remove the things for the webradio table. ( the other 3 tables also the same) I appriciate if anyone could help me in this problem I've been having.

A: 

If you are reusing the table cells across tables, then this might help:

if ([mainDataCenter.favoriteArtistArray count] == 0)
{
    [label setHidden:NO]; // show label if it was hidden
    [label setTextColor:[UIColor whiteColor]];
    [label setText:@"AUCUN FAVORI DE FICHE ARTISTE"];
}
else
{
    [label setHidden:YES];
}
gerry3
A: 

Yes thanks to your reply but I've tried this way already, still did not work. But I have solved the problem. Just remove the damn if else statement. It will work fine. kaka

Rocker