Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to remove cells from UITableView directly?

is it possible to remove a cell from UITableView directly, with animation? Without changing datasource and then reloading table data?

Thanks.

like image 865
Ilya Suzdalnitski Avatar asked Apr 10 '09 20:04

Ilya Suzdalnitski


People also ask

What is the difference between UITableView and UICollectionView?

For the listing details of each item, people use UITableView because it shows more info on each item. The UICollectionView class manages an ordered collection of data items and presents them using customizable layouts.

How can we use a reusable cell in UITableView?

For performance reasons, a table view's data source should generally reuse UITableViewCell objects when it assigns cells to rows in its tableView(_:cellForRowAt:) method. A table view maintains a queue or list of UITableViewCell objects that the data source has marked for reuse.

How do you customize swipe edit buttons in UITableView?

As of iOS 8.0 there's an easy way to customize the list of buttons that appear when the user swipes from right to left: editActionsForRowAt . Return an array of UITableViewRowAction objects that have titles and styles (and also background colors if you want to customize their appearance), and iOS does the rest.


1 Answers

In UITableView you have the method:

 (void)deleteRowsAtIndexPaths:(NSArray *)indexPaths withRowAnimation:(UITableViewRowAnimation)animation;

There's a similar method to remove a section.

However, you had better have your data model updated just before you call or else scrolling the table may yield odd results!

like image 69
Kendall Helmstetter Gelner Avatar answered Sep 22 '22 01:09

Kendall Helmstetter Gelner