Bug in UITableView ( deleteSections:withRowAnimation: )?

I have problems using this UITableView method:

- (void)deleteSections:(NSIndexSet *)sections withRowAnimation:(UITableViewRowAnimation)animation

First the documentation says:

animation: YES to animate the deletion of sections, otherwise NO.

But the parameter animation is actually of type enum UITableViewRowAnimation, not BOOL!?

So how can I disable the animation? I've tried NO and UITableViewRowAnimationNone. Nothing works. The section deletion is always animated.

I know that I can use [tableView reloadData] instead. That would solve my issue. I'm just curious if that is a known problem and if it is possible to disable animation with this tableview method.

Thanks!

Answers


About the YES/NO in the doc whereas the parameter is of type UITableViewRowAnimation, I guess this is a rest from an old version of the API where the parameter was a BOOL before. Anyway, the documentation is indeed wrong.

Don't hesitate to send a feedback to Apple for this (using the "It's good but…" link at the bottom of the doc)


It's kind of a hack but this gets rid of the insert animation:

[UIView setAnimationsEnabled:NO];
[self.tableView insertRowsAtIndexPaths:insertedIndexPaths withRowAnimation:UITableViewRowAnimationNone];
[UIView setAnimationsEnabled:YES];

Well, obviously the documentation is indeed buggy. The parameter you pass says how you animate the deletion. If you pass UITableViewRowAnimationNone, the update happens instantly without animation. However, when you have a section below the one you delete, it will move upwards in an animated way.

You should try to make use of the animations. This way a user can see what happens.


I believe you need to embed the deleteSections call inside a beginUpdates block:

[tableView beginUpdates];
[tableView deleteSections:... withRowAnimation:... ];
[tableView endUpdates];

The documentation seems to say this anyway. I haven't tested this with UITableRowViewAnimationNone though.


Need Your Help

Rails 3 ActiveRecord: Order by count on association

mysql ruby-on-rails ruby-on-rails-3 activerecord

I have a model named Song. I also have a model named Listen. A Listen belongs_to :song, and a song :has_many listens (can be listen to many times).

My Wpf Application cannot locate resource 'Mainwindow.xaml'

wpf vb.net xaml

I have been working on a wpf application using vb.net , i recently run into a problem...