Avoid automatically resizing uitableview cellular content when entering edit mode

I have a uitableviewcell with content containing a custom view. 'When the table view goes into edit mode, the content view changes (becomes narrower), so the image in the content view decreases horizontally

Does anyone know how to prevent this?

I set the cell indent to none.

thanks

+4
source share
3 answers
+2
source

Have you tried to set auto-resize masks in the view?

 theView.autoresizingMask = UIViewAutoresizingNone; 

You may need to set it in the content view and / or as an image - it is not clear how the hierarchy of your presentation is structured. However, the frame can be set explicitly (and not automatically changed) by the framework, and in this case this will not work.

If you are trying to create a background image for an entire table cell, you can also try an alternative method, which should set the backgroundColor cell as follows:

 UIImage* someImage = [UIImage imageNamed:@"someImage"]; cell.backgroundColor = [UIColor colorWithPatternImage:someImage]; 

Remember to make sure that the backgroundColor all the other views that you place inside is [UIColor clearColor] so that you can see the background image.

+1
source

You can always get a tableviewcell with a pointer. Using this tableviewcell ID repeater, you can avoid resizing the contents of the table cell. I had a requirement to implement similar functionality in order to avoid resizing individual cells. PFB code.

 -(BOOL)tableView:(UITableView *)tableView shouldIndentWhileEditingRowAtIndexPath:(NSIndexPath *)indexPath{ BOOL shouldIndentWhileEditingRow = NO; UITableViewCell *lTableViewCell = [tableView cellForRowAtIndexPath:indexPath]; /*Change the position of the target rect based on Sending messages or Receiving messages*/ if ([lTableViewCell.reuseIdentifier isEqualToString:@"SendingChatCellIdentifier"]) { shouldIndentWhileEditingRow = NO; }else if ([lTableViewCell.reuseIdentifier isEqualToString:@"ReceivingChatCellIdentifier"]){ shouldIndentWhileEditingRow = YES; } return shouldIndentWhileEditingRow; } 
0
source

All Articles