2013-05-09 21 views
1

我有一個UITableView。當用戶點擊Edit(位於例如對項目進行排序)我在UITable視圖,完成按鈕,刪除效果

- (void)setEditing:(BOOL)editing animated:(BOOL)animate { 

進入但當用戶完成(和點擊完成的),還有一個動畫。我如何刪除似乎重新加載單元格的動畫。

感謝

編輯:只是想出了這個方法又被稱爲

- (void)controller:(NSFetchedResultsController *)controller 
    didChangeObject:(id)anObject 
     atIndexPath:(NSIndexPath *)indexPath 
    forChangeType:(NSFetchedResultsChangeType)type 
     newIndexPath:(NSIndexPath *)newIndexPath { 

是有辦法去掉這個調用?

回答

0

使用這種方式:

- (void)setEditing:(BOOL)editing animated:(BOOL)animate { 
    if(editing) 
     [super setEditing:editing animated:YES]; 
    else 
     [super setEditing:editing animated:NO; 
} 
+0

感謝的點擊呼叫功能,但我的意思是它出現的編輯不上單擊編輯按鈕後,動畫,但點擊完成按鈕 – Max 2013-05-09 06:27:51

+0

看到我編輯的答案 – Anil 2013-05-09 06:34:07

+0

erf,它不起作用 – Max 2013-05-09 06:38:04

0

不能刪除。當表視圖進入並退出編輯模式時,tableView將自動重新加載可見單元格。這實際上是一個可接受的行爲編輯模式應該改變tabelView單元格中的內容(插入或刪除單元格或編輯一些值)。所以爲了反映你需要重新加載這些單元的變化。 TableView將爲您完成這項工作。它會調用cellForRowAtIndexPath的可見單元格

+0

謝謝,我剛編輯我的問題 – Max 2013-05-09 06:49:16

0

這個添加到你做

NSInteger rows; 
rows = [self tableView:tableView numberOfRowsInSection:section]; 

for (int i=0; i<rows; i++) 
{ 
NSIndexPath *tmpIndexPath = [NSIndexPath indexPathForRow:i inSection:section]; 
[tmpArray addObject:tmpIndexPath]; 
} 

UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath]; 
[tableView insertRowsAtIndexPaths:tmpArray withRowAnimation:UITableViewRowAnimationNone];