Change Position UITableViewCellEditingStyle

How to change the position of the delete button when using UITableViewCellEditingStyle from right to left?

+6
source share
5 answers

You cannot change the position of your own delete button. In the place where the default delete button uses a custom button, make them hide. Press the edit button to display them. To create a button, use this formate, it will solve your problem, write this code in the cellforrowAtindexPath method.

UIButton*Delete_btn = [UIButton buttonWithType:UIButtonTypeCustom]; [Delete_btn addTarget:self action:@selector(Delete:) forControlEvents:UIControlEventTouchUpInside]; Delete_btn.frame = CGRectMake(05, 10, 56, 56); [Delete_btn setBackgroundImage:[UIImage imageNamed:@"delete_btn.png"] forState:UIControlStateNormal]; [cell.contentView addSubview:Delete_btn]; 
+1
source

You can subclass UITableViewCell, add a delete button and add uiview over the button in the cell content view. The code will be such as to add subviews to the cell class

 [self.contentView addSubView:button]; [self.contentView insertSubview:view aboveSubview:button]; 

Add a napkin gesture to uiview, making the direction of movement to the right. When the button is pressed, you can add a delegate to send back to the controller to delete the cell and reload the table. You can also do this with the nib file by first placing the delete button and then uiview. Hope this helps.

0
source

There is no built-in method to reposition the delete button in a UITableViewCell. You must create a custom class, which is a subclass of UITableViewCell, and make the cell UI with XIB or code no matter what you select, and also provide the appropriate elements and actions to the cell elements.

0
source

You cannot change the position of your own delete button. You can subclass UITableViewCell and create a button yourself by placing it (hidden) on the left edge, and in the button callback, move the contents of the cell to the right.

0
source

You can use a custom button in your / xib storyboard, and then use the [* buttonObject addTarget] method to recognize the click event. This is the easiest way to customize your table view without using your own accessories.

0
source

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


All Articles