2009-11-04 59 views
0

我有3張稱爲收音機,歌曲和藝術家的表格。 現在,我想在表格中沒有任何內容時爲每個表格顯示不同的文本。但是我希望在桌子內有東西時刪除文字。我可以通過添加標籤來顯示文本。如何隱藏和顯示錶格中的標籤?

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

但文字是隱藏在一個表後(意思是有一些僅添加到特定的表),但在其他表中的其他文本也消失了。

- (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];  
    } 

這是我刪除webradio表的東西的代碼。 (其他3張桌子也一樣) 我很有趣,如果有人可以幫我解決這個問題,我一直在。

回答

0

如果你重用跨表的表格單元格,則這可能幫助:

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]; 
} 
0

是感謝您的答覆,但我已經試過這種方式已經,仍然沒有工作。但我已經解決了這個問題。只要刪除該死的if else語句。它會正常工作。卡卡