2011-02-08 3 views
0

私は次のコードを使用してテーブルビューから行を削除します。 行はdbから一度に削除されますが、テーブルビューからは削除されません。私は行tableviewを削除する必要がありますデータをrloadする必要があります... 任意のアイデア?テーブルreloadDataが動作しない

-(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]; 
    [dbmethods release];  
    } 
    [self.table reloadData];//its not working reload data... 
    [table endUpdates]; 
} 

答えて

0

self.tableとは何ですか? UITableViewのクラス変数ですか? UITableViewは、そのメソッドにtableViewとして渡されるため、直接参照することもできます。 table変数が正しく設定されていないか(Interface Builder経由で)何か、しかしtableView変数を使ってみてください。

+0

にはいその私のクラスのUITableViewの変数、およびnibファイルテーブルには、クラス変数テーブルに(引き渡し)を割り当てます.... – Haseeb

1

[self.allBookMarks removeObjectAtIndex:indexPath.row]; 

、この行を含めEDIT:問題はreloadDataではない

、問題はあなたのデータソース(self.allBookMarks)を更新していないということです。値をself.allBookMarksに更新し、表をリロードします。

編集コード

-(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]; 
} 
+0

それが動作していない無先生、それはこのアプリを追加する前に、 をアプリクラッシュさせています。しかし、このコードを追加すると、他のアイデアはなくなりますか? – Haseeb

+0

あなたはallBookmarkにthisBookのようないくつかの他の配列を参照したと思います。allBookMarks = someArray、allArrayからオブジェクトを取り除くとsomeArrayからも削除されます。すべてのブックマーク= [someArray retain];あなたは何の墜落もしません。 – KingofBliss

+0

[dbmethods deleteBookMark:delHaditid]のコードを投稿してください。 – KingofBliss

関連する問題