views:

183

answers:

2

Is there any way to decrease the standard width of grouped UITableViewCell and put a custom button on the left side(outside of cell boundary)? I tried to change the cell size but it keeps same

alt text

A: 

You could subclass UITableCell and add your own custom views inside of it. I have not personally added a button inside one but it should work. It may get confused with the row selected call the tableview makes if you are implementing that.

AtomRiot
Actually I want to draw the button outside, that's why I asked how to decrease the size of cell.
Michael
You want the button outside and to scroll with it?
AtomRiot
Yes, it would be some quick action button for each cell.
Michael
Updated with screenshot
Michael
+1  A: 

You are going to have to fake the editing mode. What I mean by that is that as AtomRiot said you have to subclass UITableViewCell so that when in editing mode you show the button you want on the left, outside the cell.

But first things first. To change the indentation level for your cells all you need to do is implement this delegate method for the UITableView

- (NSInteger)tableView:(UITableView *)tableView indentationLevelForRowAtIndexPath:(NSIndexPath *)indexPath

So that takes care of it. Then in your UITableViewCell subclass all I would do is to implement the method

- (void)setEditing:(BOOL)editing animated:(BOOL)animated {

which I assume is called when the table the cell belongs to has changed to editing mode. There I would fade in (or animate in any way you want) a button to appear on the left of your cell. I have done it inside a grouped-style cell but never on the outside. Give it a try!

Emerson
@Emerson: I actually want it to be in regular mode, not edit. So I guess I can do it in drawRect of my subclassed `UITableViewCell`? Thanks for your time.
Michael