2012-03-07 139 views
2

我想補充我的sliderButton動畫結束後,但是,這並不工作,它增加了按鍵,而部分的缺失正在動畫。呼叫後[self.tableView endUpdates]的方法結束

[coursesTable beginUpdates]; 
    [coursesTable deleteSections:[NSIndexSet indexSetWithIndex:0] withRowAnimation:UITableViewRowAnimationTop]; 
    [coursesTable endUpdates]; 
    [self.view addSubview:sliderButton]; 

當動畫結束時,是否有可能調用這樣的方法?

+0

添加一些動畫的sliderButton,以便在該部分的刪除動畫完成後添加您的按鈕。 – hchouhan02 2012-03-07 08:30:07

回答

0

我還沒有發現this.I的解決方案必須使用performSelector:withObject:afterDelay:對於我的工作做完。

0
[coursesTable deleteSections:[NSIndexSet indexSetWithIndex:0] withRowAnimation:UITableViewRowAnimationTop]; 

在此之後,tableview又問其數據源數據......所以所有的數據源方法,包括cellforRow又被稱爲..

我建議保持一個BOOL被刪除。

所以現在cellForRow方法做到這一點

[coursesTable beginUpdates]; 
     [coursesTable deleteSections:[NSIndexSet indexSetWithIndex:0] withRowAnimation:UITableViewRowAnimationTop]; 
     [coursesTable endUpdates]; 
Deleting = YES; 

{ 
if (index path.row == lastrow) // last rowcell is reached 
if(Deleting) 
{ 
//tableView has reloaded. 
    [self.view addSubview:sliderButton]; 
    Deleting = NO;; 


} 
} 
4

我相信,在animateWithDuration包裹你的表更新將工作:

[UIView animateWithDuration:0.0 animations:^{ 
    [coursesTable beginUpdates]; 
    … 
    [coursesTable endUpdates]; 
} completion:^(BOOL finished) { 
    // Code to run when table updates are complete. 
}]; 

其他方法,我發現這裏建議堆棧溢出沒有爲我工作。

我一次使用這種技術,並且測試它足以驗證完成塊是在我調用表的endUpdates方法後調用的,但是重寫了我的代碼,因此在我完全驗證之前不需要它動畫實際上完成了。

+0

使用此方法將跳過動畫的動畫部分,只需即時完成,即使您放置的時間更長,如1.0。 – 2016-09-10 19:23:02