我有一个名为favorite的选项,每次我选择我最喜欢的歌曲时,这首歌都会被添加到那个最喜欢的选项中。所以我为它做了一个表格,每个单元格都会存储我选择的每首歌。我也可以删除这首歌。但在我选择任何歌曲之前,我想让它在表格中显示一些通知文本。或者,当我完全删除收藏夹中的所有内容时,我希望出现相同的文本,并且每次添加任何内容时,它都必须消失。有人能告诉我怎么做吗?
// DELETE FAVORITE
-(void)tableView:(UITableView*)tableView willBeginEditingRowAtIndexPath:(NSIndexPath *)indexPath
{
}
- (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];
}
}下面是我的代码,用于删除该表中的行。
发布于 2009-11-03 00:21:07
我在这里回答了你的问题:insertion and deletion in the table of objective C
但我假设你使用的是OS,在iPhone上你会做同样的事情,但方法是:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPathhttps://stackoverflow.com/questions/1660264
复制相似问题