O'Reilly logo

Mastering iOS 11 Programming - Second Edition by Donny Wals

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Allowing the user to reorder cells

In some applications it makes sense for users to reorder the cells shown in a UITableView. For example, if you are building a list of a user's favorite contacts or a list that simply doesn't have any logical order where it makes sense for users to reorder it to their own taste. In order to implement reordering in UITableView, we will need to do a couple of things.

First of all, you'll need a way to enter editing mode for UITableView. The easiest way to achieve this is by wrapping your ViewController in a UINavigationController. This will provide the app with a nice bar at the top of the screen, which is a perfect place to add an Edit/Done button.

UIViewController actually has a very nice convenience method ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required