table reloadData not working

拥有回忆 提交于 2019-12-02 07:54:21

Include this line,

[self.allBookMarks removeObjectAtIndex:indexPath.row];

EDIT:

The problem is not with reloadData, the problem is that you are not updating your datasource (self.allBookMarks). Update the values into self.allBookMarks then reload the table.

Edited Code

-(void) tableView:(UITableView *)tableView
commitEditingStyle:(UITableViewCellEditingStyle)editingStyle 
forRowAtIndexPath:(NSIndexPath *)indexPath 
{
    [self.table beginUpdates];

  if (editingStyle == UITableViewCellEditingStyleDelete) 
  { 
    Hadits *delHadit = [self.allBookMarks objectAtIndex:indexPath.row];
    dbAccess *dbmethods = [[dbAccess alloc] init]; 
    NSInteger delHaditid = delHadit.haditid;
    [dbmethods deleteBookMark:delHaditid];
    self.allBookMarks = [dbMethods getAllBookMarks]; 
    [dbmethods release];    
  }
  [self.table reloadData];//its not working reload data...
  [table endUpdates];
}

What is self.table? Is it your class variable for your UITableView? You should note that you can also reference the UITableView directly since it is passed into that method as tableView. I dunno if your table variable isn't setup correctly (through Interface Builder) or what, but I'd try using the tableView variable.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!