uitableview delete button image in iOS

Sudha Tiwari

I want to change swipe button image of uitableview cell. I have searched for it but I am not get desired result. I have used this code:

- (void)willTransitionToState:(UITableViewCellStateMask)state{
    [super willTransitionToState:state];
    if ((state & UITableViewCellStateShowingDeleteConfirmationMask) == UITableViewCellStateShowingDeleteConfirmationMask) {
        for (UIView *subview in self.subviews) {
            if ([NSStringFromClass([subview class]) isEqualToString:@"UITableViewCellDeleteConfirmationControl"]) {
                UIImageView *deleteBtn = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, 64, 33)];
                [deleteBtn setImage:[UIImage imageNamed:@"delete.png"]];
                [[subview.subviews objectAtIndex:0] addSubview:deleteBtn];

            }
        }
    }
}

But this is not working in iOS 9. Please suggest me how to achieve this in iOS 9.

If I used this code then its working but image is not set properly:

[[UIButton
      appearanceWhenContainedIn:[TableViewCell class], nil]
     setImage:[UIImage imageNamed:@"Delete-notification.png"] forState:UIControlStateNormal];


-(NSArray *)tableView:(UITableView *)tableView editActionsForRowAtIndexPath:(NSIndexPath *)indexPath {
 UITableViewRowAction *button = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleDefault title:@"Button 1" handler:^(UITableViewRowAction *action, NSIndexPath *indexPath)
    {
        NSLog(@"Action to perform with Button 1");
    }];


    return @[button];
}

like this]1

Thanks in advance!

Ekta Padaliya

I am using this library https://github.com/CEWendel/SWTableViewCell to display image on swipe button.

#import "SWTableViewCell.h"

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
        SWTableViewCell  *cell = [tableView dequeueReusableCellWithIdentifier:@"idTipsCell"];
        [cell setLeftUtilityButtons:[self leftButtonsWithColor:tipsData.color accessibilityValue:(tipsData.isLiked) ? @"1":@"0"] WithButtonWidth:80.0];
        cell.delegate = self;
        return cell;
  }

- (NSArray *)leftButtonsWithColor:(UIColor*)color accessibilityValue:(NSString*)accessibilityValue {
     NSMutableArray *leftUtilityButtons = [NSMutableArray new];

     [leftUtilityButtons sw_addUtilityButtonWithColor:color icon:[UIImage imageNamed:@"img_like"] accessibilityValue:accessibilityValue];
     [leftUtilityButtons sw_addUtilityButtonWithColor:color icon:[UIImage imageNamed:@"img_share"] accessibilityValue:@"shareButton"];

     return leftUtilityButtons;
 }

Hope it will help you.

Este artículo se recopila de Internet, indique la fuente cuando se vuelva a imprimir.

En caso de infracción, por favor [email protected] Eliminar

Editado en
0

Déjame decir algunas palabras

0Comentarios
Iniciar sesiónRevisión de participación posterior

Artículos relacionados

UITableView edit mode delete button is hiding in IPhone 4s

iOS UITableView: кнопка очистки раздела

ios: UITableView показывает данные, когда я нажимаю на них

iOS - некоторые точки в ячейке UITableView недоступны для выбора

iOS Swift Add SVG Image to button like Android

iOS 15: удалить пустое пространство перед ячейками в UITableView

iOS 8: как программно установить высоту для UITableview в ViewController произвольной формы

IOS: как использовать UITableView в качестве представления ленты новостей для приложения типа Facebook

Как использовать UITableView и NSLink вместе в Swift iOS?

iOS UITableView Offset Refresh Control

How to add UIProgressView in UITableView in iOS

iOS UITableView 不顯示

Make a button with an image

Image-button with css

Display image on a Java button

svg image as button in flutter

WPF radio button with Image

Agregar UILongPressGesture a UITableView en iOS13

iOS UITableView cell fit to screen width

UITableView Suppression de lignes dans iOS 11

iOS UITableView verschiebt Zellen im Code

iOS UITableView reloadData muestra una pantalla vacía

¿Equivalente de iOS UITableView para WPF?

UITableView con categorías jerárquicas -Swift iOS

UITableView header view overlap cells in iOS 10

iOS UITableView reloadData muestra una pantalla vacía

Adding UILongPressGesture to UITableView in iOS13

¿Equivalente de iOS UITableView para WPF?

ios: UITableView muestra datos cuando lo toco