Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/120.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 将背景图像添加到UITableViewRowAction按钮_Ios_Uitableview_Uitableviewrowaction - Fatal编程技术网

Ios 将背景图像添加到UITableViewRowAction按钮

Ios 将背景图像添加到UITableViewRowAction按钮,ios,uitableview,uitableviewrowaction,Ios,Uitableview,Uitableviewrowaction,我正在使用UITableViewRowAction。我的要求是,在表单元格的左滑动中,我应该显示2UITableViewRowAction按钮。我可以通过实现-(NSArray*)tableView:(UITableView*)tableView editActionsForRowAtIndexPath:(nsindepath*)indepath来实现这一点。这是代码 -(NSArray *)tableView:(UITableView *)tableView editActionsForRow

我正在使用UITableViewRowAction。我的要求是,在表单元格的左滑动中,我应该显示2
UITableViewRowAction按钮
。我可以通过实现
-(NSArray*)tableView:(UITableView*)tableView editActionsForRowAtIndexPath:(nsindepath*)indepath来实现这一点。这是代码

-(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 greenColor]; //arbitrary color
    UITableViewRowAction *button2 = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleDefault title:@"Edit" handler:^(UITableViewRowAction *action, NSIndexPath *indexPath)
                                 {
                                     NSLog(@"Action to perform with Button2!");
                                 }];
    button2.backgroundColor = [UIColor redColor]; //arbitrary color

    return @[button, button2];
}
目前我正在使用一些任意颜色作为
按钮
按钮2
的背景

但我的要求是有一个背景图像,而不是一些颜色。我仔细阅读了给出的答案,并尝试通过添加

button.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"icon_ab_delete.png"]];
而不是

button.backgroundColor = [UIColor greenColor];
我的项目中存储了icon\u ab\u delete.png。但是,当我运行我的应用程序时,我会得到一个白色背景,上面什么都没有。大概是这样的:

编辑后的按钮(本来应该是用于删除的)没有显示任何内容,它确实存在,因为我仍然可以在它的处理程序中捕获我正在尝试执行的事件

我想知道我是否正确设置了背景图像,或者是否有其他方法来实现我的目标

提前谢谢