我有三个表,分别是电台,歌曲和艺术家,由收藏控制。现在,当表中没有任何内容时,我希望为每个表显示不同的文本。但我希望当表中有内容时,文本被删除。我可以通过添加标签来显示文本。
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];
}这是我删除网络广播表格内容的代码。(其他3个表也一样)如果有人能帮我解决我一直遇到的这个问题,我很高兴。
发布于 2009-11-04 17:29:08
如果要跨表重用表单元格,这可能会有所帮助:
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];
}发布于 2009-11-05 11:06:30
我删除了if else语句,它工作得很好。
https://stackoverflow.com/questions/1671777
复制相似问题