Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Make only certain sections of UITableView editable

I have a UITableView with multiple sections, and I want to make only one section editable (swipe to delete).

I have a feeling I have to do something in the willBeginEditingRowAtIndexPathdelegate method, but I can't seem to figure it out.

like image 974
shabbirv Avatar asked Mar 06 '26 01:03

shabbirv


2 Answers

Use

- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath

return YES for allowing editable, otherwise NO.

like image 115
Hanon Avatar answered Mar 08 '26 13:03

Hanon


You can use the below function for what you look for:

-(BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath

Return YES to whichever row you want to edit.

like image 35
cocoakomali Avatar answered Mar 08 '26 15:03

cocoakomali



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!