tablerow删除但仍在表视图中显示 [英] tablerow delete but still showon in table view
本文介绍了tablerow删除但仍在表视图中显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的数据显示在表格上,当我选择数据来从数据库中删除它而不是从表中删除时,我回到其他视图并再次进入删除表视图然后删除数据不再显示
i我正在使用此代码......
my data is show on the table whn i select data to delet its delted from database but not from table , i go back to other view and again come to the delete table view then delete data is not show again i am using this code ...
- (void)deleteRowsAtIndexPaths:(NSArray *)indexPath withRowAnimation:(UITableViewRowAnimation)animation
{
NSLog(@"Hello");
}
-(void) tableView:(UITableView *)tableView
commitEditingStyle:(UITableViewCellEditingStyle)editingStyle
forRowAtIndexPath:(NSIndexPath *)indexPath
{
// int row = [indexPath row];
[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];
[dbmethods release];
}
[self deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath]
withRowAnimation:UITableViewRowAnimationFade];
[self.table endUpdates];
NSLog(@"Hello");
[self.table reloadData];
}
...需要帮助..
问候Haseeb
...Help needed.. Regards Haseeb
推荐答案
没有错误(或者我认为没有显示相关代码)。您已从数据库中删除了该条目,但我认为您错过了从您的数组中删除该条目作为您的tableview数据源。
There is little mistake (or I think the relevant code is not shown). You have deleted the entry from the database, but I think you have missed to delete the same from your array which acts as your tableview datasource.
-(void) tableView:(UITableView *)tableView
commitEditingStyle:(UITableViewCellEditingStyle)editingStyle
forRowAtIndexPath:(NSIndexPath *)indexPath
{
[self.table beginUpdates];
if (editingStyle == UITableViewCellEditingStyleDelete)
{
// [self.table deleteRowsAtIndexPaths:[NSArray arrayWithObject: indexPath] withRowAnimation:UITableViewRowAnimationFade];
Hadits *delHadit = [self.allBookMarks objectAtIndex:indexPath.row];
dbAccess *dbmethods = [[dbAccess alloc] init];
NSInteger delHaditid = delHadit.haditid;
[dbmethods deleteBookMark:delHaditid];
[dbmethods release];
[self.allBookMarks removeObject:delHadit];/// change of code
}
//[self.table reloadData];
[table endUpdates];
}
这篇关于tablerow删除但仍在表视图中显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文