Pavan
Pavan

Reputation: 18498

Rearrange cells in tableview during runtime

Could someone please point me in the right direction on how to allow the cells to be able to move in a UITableView?

At the moment when I click and hold and then drag below the second cell it doesn't move. It just drags all the cells with it and stretches back up again.

I would like to be able to move the cells so I can basically rearrange the cells during runtime. can someone please help me.

Upvotes: 0

Views: 2153

Answers (3)

Kyle Emmanuel
Kyle Emmanuel

Reputation: 2221

You can only rearrange tableview cells when in edit mode.

look for this line of code within your program :

// Uncomment the following line to display an Edit button in the navigation bar for this view controller.
self.navigationItem.rightBarButtonItem = self.editButtonItem; 

It should be commented if you haven't touched it yet.

cheers !

Kyle

Upvotes: 2

Hemant Singh Rathore
Hemant Singh Rathore

Reputation: 2139

Try this

- (void) tableView:(UITableView *)tableView
moveRowAtIndexPath:(NSIndexPath *)fromIndexPath 
       toIndexPath:(NSIndexPath *)toIndexPath 

Upvotes: 1

Stefan Arentz
Stefan Arentz

Reputation: 34935

This is functionality that the UITableView provides for you.

Check the Managing the Reordering of Rows section in the TableView Programming Guide.

Upvotes: 3

Related Questions