2012-03-07 13 views
2

アニメーションが終了した後にsliderButtonを追加したいが、これが機能しない場合、セクションの削除がアニメーション化されている間にボタンを追加する。[self.tableView endUpdates]が終了した後にメソッドを呼び出す

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

アニメーションが終了したときに私のための方法を呼び出すことは可能でしょうか?

+0

スライダボタンにアニメーションを追加すると、セクションのアニメーションが完了した後にボタンが追加されます。 – hchouhan02

答えて

0

私はこの解決策を見いだせませんでした。私はperformSelector:withObject:afterDelay:を使用しなければなりません。このtableviewは再びそのデータソースからのデータを要求した後

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

...再び呼び出され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. 
}]; 

他の方法をそのIここに示唆されたスタックオーバーフローは私にとってはうまくいかなかった。

このテクニックを一度に使用し、テーブルのendUpdatesメソッドを呼び出した後に完了ブロックが呼び出されたことを検証するのに十分なテストを行いましたが、コードを書き直してから、アニメーションは実際に終了しました。

+0

このメソッドを使用すると、アニメーションのアニメーション部分をスキップし、1.0のような長い期間を置いても、ただちに完了させることができます。 –

関連する問題