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 nav开发者_运维知识库igation 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?
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).
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.
精彩评论