UITableViewCells resizes in edit mode

I want to change the appearance of a UITableviewCell in edit mode, as shown in the address book from apple. The cell should resize and I will add UITextFields as subzones. I know that to change the appearance of a cell, you need to overwrite the LayoutSubviews function in the cell. I tried to do this and I had funny effects and resizing :-)

I searched for a while to find online hints, but I did not find it. If anyone can give some clues, how to do it right? Links to textbooks or code will be fine.

Thanks Eddy

+4
source share
4 answers

It is not recommended to overwrite setEditing:animated: and reload table cells. This is a very expensive resource, and not a suitable place for this.

In a subclass of UITableViewCell , the didtransitionToState override method: There you can act directly on cells, for example:

  - (void)didTransitionToState:(UITableViewCellStateMask)state { [super didTransitionToState:state]; if (state == UITableViewCellStateShowingEditControlMask) { // edit mode : peform operations on the cell outlets here } else if (state ==UITableViewCellStateDefaultMask) { // normal mode : back to normal } 
+4
source

when you set myTable.editing=YES; , it calls the table and delegate data presentation method.

therefore, if you have data to display in the table, the above line of code calls the delgate method

so you can code here

 - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { if(myTable.editing==YES) { return 70;//customize it. } return 50; } 
+1
source

If you want to change the cell height size, you must also change the "heightForRowAtIndexPath" in your UITableView Delegate. At least that's what I came across several times.

0
source

Overwrite setEditing:animated: and reload the table table cells.

0
source

Source: https://habr.com/ru/post/1342807/


All Articles