views:

400

answers:

2

Hello

I have a UIViewController, and within that view i have UITableView added in IB

The UITableView displays the items from my array beautifully

I would like to be able to edit the items i.e delete them

BUT The UITableView does not have a navigation bar, and i am not using a navigation controller within this app i am just adding and removing views manually.

What i would like to do is place an "edit" button somewhere else within the view ... is this possible? and how might i go about this?

A: 

Put a button somewhere. In an action connected to it set TableView's editing property to YES - it should work fine. You also need to implement delegate's editingStyleForRowAtIndexPath method (return UITableViewCellEditingStyleDelete to allow to delete cells).

Vladimir
Hi Vladimir - i have got it so that a button sets the editing property to YES, and that works fine...but how can you make it so that the button once clicked again then stops the user from editing?
Tom G
tableView.editing = !tableView.editing and set button title according to this editing value?
Vladimir
A: 

You could make one special cell (e.g. 1st row, 1st group) a button by implementing a adaequate didSelectRowAtIndexPath.

Or you could put buttons for editing/deleting in each cell (if single deletion/editing makes sense).

Or you could place the UIIableView on a super view wich also contains the button(s) as sub views.

Kai