删除行后添加文本

时间:2009-11-02 09:40:10

标签: iphone objective-c cocoa-touch

我有一个名为收藏的选项,每次我选择自己喜欢的歌曲时,歌曲都会添加到最喜欢的选项中。所以我为它制作了一张桌子,每个单元格都会存储我选择的每首歌曲。我也可以删除这首歌。但在我选择任何一首歌之前,我想让它显示一些通知文字。或者当我完全删除所有内容中的所有内容时,我希望显示相同的文本,并且每次添加任何内容时它都必须消失。有人能告诉我怎么做吗?

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

这是我的代码,用于删除该表中的行。

1 个答案:

答案 0 :(得分:0)

我在这里回答了你的问题:insertion and deletion in the table of objective C

但是我假设你使用OS X,在iPhone上做同样的事情,但方法是:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath