Created
December 29, 2022 13:45
-
-
Save DevGW/a28b182bfc28cfc3ca41dd6130e76bac to your computer and use it in GitHub Desktop.
Objective-C :: UITableView Slide to Multi
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-(NSArray *)tableView:(UITableView *)tableView editActionsForRowAtIndexPath:(NSIndexPath *)indexPath { | |
UITableViewRowAction *button = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleDefault title:@"Delete" handler:^(UITableViewRowAction *action, NSIndexPath *indexPath) | |
{ | |
NSLog(@"Action to perform with Button 1"); | |
}]; | |
button.backgroundColor = [UIColor redColor]; //arbitrary color | |
UITableViewRowAction *button2 = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleDefault title:@"Mark\nRead" handler:^(UITableViewRowAction *action, NSIndexPath *indexPath) | |
{ | |
NSLog(@"Action to perform with Button2!"); | |
}]; | |
button2.backgroundColor = [UIColor crayolaMidnightBlueColor]; //arbitrary color | |
return @[button, button2]; //array with all the buttons you want. 1,2,3, etc... | |
} | |
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath { | |
// you need to implement this method too or nothing will work: | |
} | |
- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath | |
{ | |
return YES; //tableview must be editable or nothing will work... | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment