5

I am using following code for swipe UITableViewCell in xcode6 with ios8.0.My code is working fine,but i need to set equal width for UITableViewRowActions (more,Delete,etc).How is that possible?Please help me..

 -(NSArray *)tableView:(UITableView *)tableView editActionsForRowAtIndexPath:(NSIndexPath *)indexPath {

 UITableViewRowAction *moreAction = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleDefault title:@“More” handler:^(UITableViewRowAction *action, NSIndexPath *indexPath){


 }];

UITableViewRowAction *flagAction = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleDefault title:@“Flag” handler:^(UITableViewRowAction *action, NSIndexPath *indexPath){

 }];

 UITableViewRowAction *deleteAction = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleDefault title:@"Delete"  handler:^(UITableViewRowAction *action, NSIndexPath *indexPath){
   // [self.objects removeObjectAtIndex:indexPath.row];
 }];

 return @[deleteAction,flagAction,moreAction];

 }
IKKA
  • 6,297
  • 7
  • 50
  • 88
  • Let's be happy that we already have an opportunity to access this private API, that was not available to public until current iOS 8. Probably Apple is going to allow us to customize this stuff in next iOS version. – pedrouan Oct 15 '14 at 12:41
  • width of row action is defined by length of title. What you can do is to add spaces as prefixes and sufixes so that resulting labels will have same width. Or check my answere here: http://stackoverflow.com/questions/26887563/how-to-change-uitableviewrowaction-title-color?lq=1 – Tankista Nov 28 '14 at 01:05

1 Answers1

1

I know that It's way far from perfect but I added empty string for the title

[UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleDefault title:@"       "

and then I used images

block.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"block"]];

enter image description here

johnny
  • 555
  • 4
  • 16