2012-03-07 141 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