开发者

Decrease UITableViewCell width and put custom button on the left

开发者 https://www.devze.com 2023-01-03 23:04 出处:网络
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 k开发者_运维百科ee

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 k开发者_运维百科eeps same

Decrease UITableViewCell width and put custom button on the left


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!


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.


The Cocoanetics blog seems to have a pretty good solution to this: http://www.cocoanetics.com/2010/03/how-to-shrink-cells/

0

精彩评论

暂无评论...
验证码 换一张
取 消