2011-08-11 47 views
0

我有一个可编辑的分组tableView,但刷卡删除不起作用。它看起来像刷卡 - 删除应该与UITableViewCellEditingStyleDelete一起,但它似乎并不适合我。这是我编辑样式的方法:TableView滑动删除不起作用

- (UITableViewCellEditingStyle)tableView:(UITableView *)table editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
    if (indexPath.section == 1) 
    {   
     if (indexPath.row < [[device_coordinator getChannelList] count]) return UITableViewCellEditingStyleDelete; 
     else if (indexPath.row < [[device_coordinator getChannelList] count]+2) return UITableViewCellEditingStyleInsert; 
    } 
    return UITableViewCellEditingStyleNone; 
} 

这使得表格看起来正确。有些单元格的左侧有插入图标,有些单元格会删除图标,因为它们应该如此。按下删除图标将显示删除确认按钮。但一个刷卡不!

即使我只是返回空白,从我的cellForRowAtIndexPath方法新分配的单元格,它仍然无法正常工作,所以看起来我的单元格中没有任何内容导致问题。在4.3模拟器和我的iPod touch 2g上发生同样的问题。

回答

0

我认为你的代码是正确的,但是如果我理解你的话,那就是一个逻辑错误。你想滑动删除编辑模式,这是不可能的。只有在用户未处于编辑模式时,才能进行滑动删除。 所以你只需要通过调用这个方法来隐藏/显示编辑图标。

-(IBAction)edit:(id)sender//action connected to edit button 
{ 
    if(yourTableView.editing) [yourTableView setEditing:NO animated:YES]; 
    else [yourTableView setEditing:YES animated:YES]; 
} 

然后滑动删除将在单元格旁边没有图标时工作。希望这可以帮助。

+0

你说得对!我希望能够同时做到这一点。但至少我知道现在不行的原因。我认为我的应用程序闹鬼。 – Randall