elp
elp

Reputation: 8131

Indent UITableViewCell while editing

how can i indent my CUSTOM CELL while editing, resizing or moving labels and images correctly?

I use:

- (BOOL) tableView:(UITableView *)tableView shouldIndentWhileEditingRowAtIndexPath:(NSIndexPath *)indexPath { 
  return YES; 
}

with no effects.

Any idea?

Upvotes: 1

Views: 3469

Answers (2)

elp
elp

Reputation: 8131

Solved animating all components (changing frame.origin.x) in this way:

- (BOOL) tableView:(UITableView *)tableView shouldIndentWhileEditingRowAtIndexPath:(NSIndexPath *)indexPath {

  [UIView beginAnimations:nil context:NULL];
  [UIView setAnimationDuration:.3];

  [cell.CellTitle setFrame:cgrectMake(x+20, y, w, h)];  // +x
  [...]
  [cell.CellAddress setFrame:f2];

  [UIView commitAnimations];

  return YES; 
}

On edit / save, animation "indent" controls left or right.

thanks

Upvotes: 1

jbat100
jbat100

Reputation: 16827

I'm not sure if I understand your question, but if you want your cell content to be indented properly when transitioning in/out of edit mode, then you should put all your cell subviews in the UITableViewCell contentView, this is the discussion:

The content view of a UITableViewCell object is the default superview for content displayed by the cell. If you want to customize cells by simply adding additional views, you should add them to the content view so they will be positioned appropriately as the cell transitions into and out of editing mode.

If you set your auto-resizing masks correctly then all the resizing should be done right.

Upvotes: 6

Related Questions