2015-05-29 1 views
0

Я создал экземпляр UITableViewRowAction вUITableViewRowAction изменение BackgroundColor на пресс

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

и у меня есть блок обработчика, когда эта строка запускается действие:

handler:^(UITableViewRowAction *action, NSIndexPath *indexPath) 

У вас есть параметр действий строки, которые могут чтобы вы не создавали циклы сохранения, и у вас есть указательный путь. Я попытался установить backgroundColor этого нового действия ряда, как это:

[action setBackgroundColor:[UIColor greenColor]]; 

Но это ничего не изменило. Я также пробовал setNeedsDisplay на объекте кнопки действия строки, но без везения.

Любая идея, как я могу изменить backgroundColor, пока действия строки все еще видны? Благодаря

  • Xcoder
+0

Опубликуйте свои инструменты 'editActionsForRowAtIndexPath' здесь – Bannings

ответ

2

Вот моя реализация того же самого, и он работает хорошо. Он также должен решить вашу проблему.

- (NSArray *)tableView:(UITableView *)tableView editActionsForRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
    UITableViewRowAction *one = [UITableViewRowAction rowActionWithStyle:0 title:@"one" handler:^(UITableViewRowAction *action, NSIndexPath *indexPath) { 

     NSLog(@"my first action"); 
    }]; 

    UITableViewRowAction *two = [UITableViewRowAction rowActionWithStyle:1 title:@"two" handler:^(UITableViewRowAction *action, NSIndexPath *indexPath) { 

     NSLog(@"my second action"); 

    }]; 

    UITableViewRowAction *three = [UITableViewRowAction rowActionWithStyle:1 title:@"three" handler:^(UITableViewRowAction *action, NSIndexPath *indexPath) { 

     NSLog(@"my third action"); 
    }]; 

    one.backgroundColor = [UIColor purpleColor]; 
    two.backgroundColor = [UIColor greenColor]; 
    three.backgroundColor = [UIColor brownColor]; 

    return @[one, two, three]; 
} 

 Смежные вопросы

  • Нет связанных вопросов^_^