views:

531

answers:

2

how do i set editing style for custom UItableviewcell like this image.alt text

this is shopping cart view ,so i am gonna have many UITableViewCell, out of other fields only Qty field is going to be editable. thanks

+2  A: 

The cell above looks like a custom button. What you can do is to add two UIButtons to a subclass of UITableViewCell, as well as a UITextField, and add event handling code for clicking the UIButtons to update the quantity. Since you can use an image for UIButtons achieving the above look shouldn't be difficult.

futureelite7
thanks futureelite7,let me try that way...
Nnp
problem i am getting right now is, this buttons should be visible only in editing mode? how do i get custom cell in editing mode?
Nnp
When the table is set into Editing mode, all UITableViewCells will have [setEditing:animated:] called. Use that method to show/hide the appropriate UI controls.
futureelite7
thanks futureelite7, here is what i am doing.in [setEditing] method, i am again calling [tableview reloaddata] and in [cellforrowatindexpath] method i am check (self.editing). if its editing then load editable cell from NIB. is this correct way, and another thing how do i catch events from cell and identify which button clicked and which textfield to get update.
Nnp
A: 

i have figure out some way, i dont know its the right way,but it works for me, but still waiting the most correct way. here is what i did,

1) i have created a IBOutlat for my UIButton in my EditCellView (subclass of UITableviewcell)
2) and then i create IBAction in my tableviewcontroller
3) then i set UIButton Touch in event to IBAction in tableviewcontroller
4) in IBaction method you can get that cell using this code

EditItemController *cell =  (EditItemController *)[[sender superview] superview];
NSIndexPath *indexPath = [self.maintable indexPathForCell:cell];

this line of code may depends on your view layout

[[sender superview] superview]

to get correct superview you can use following command in gdb

gdb>po [[sender superview] superview]
Nnp