获取 UITableView 的 IndexPath 来改变 UIView 的颜色

Get IndexPath of UITableView to change the color of a UIView

我在 tableViewCell 的左侧添加了一个徽章,如 this example 所示。 然后在成功完成之后,我转到下一件事,即在单​​元格上添加滑动 left/right 并显示一些选项。我已经通过在 GitHub 上使用 this library 成功地配置了它。

现在,当我向前移动时,我在右滑上添加了一个取消选项,用户点击它我希望徽章 (UIView) 颜色变为红色。
我已经将绿色添加到它作为 appointmentCell.appointmentStatusIndicatorBadge.layer.backgroundColor = [UIColor greenColor].CGColor; 所以如果我在 didTriggerLeftUtilityButtonWithIndex 中再次调用此行它没有选择 appointmentStatusIndicatorBadge 因为它是在 PatientAppointmentTableViewCell 中创建的@property (weak, nonatomic) IBOutlet UIView *appointmentStatusIndicatorBadge; 并在 PatientViewController

中使用

这是我需要访问它的完整方法:

- (void)swipeableTableViewCell:(SWTableViewCell *)cell didTriggerLeftUtilityButtonWithIndex:(NSInteger)index {
    switch (index) {
        case 0:
        {
            NSLog(@"Just Tapped Cancel");
//here I want to change the color to red
            [cell hideUtilityButtonsAnimated:YES];
            break;
        }
        default:
            break;
    }
}

我试图通过创建 class 的新对象来做到这一点,但这是一件愚蠢的事情。现在的问题是我无法跟踪 indexPath,因为我不再在 TableView 的委托方法中。那我该怎么做呢?


编辑
根据此处的评论是我的 tableViewCell 的 .h 代码。我没有在 .h 文件中做任何事情。

#import <UIKit/UIKit.h>
#import "SWTableViewCell.h"

@interface PatientAppointmentTableViewCell : SWTableViewCell
@property (weak, nonatomic) IBOutlet UIView *appointmentStatusIndicatorBadge;
@end

使用以下代码获取单元格的indexPath:

NSLog(@"Just Tapped Cancel");
NSIndexPath *indexPath = [tableView indexPathForCell:cell];

然而,cell 是来自以下方法的 cell

- (void)swipeableTableViewCell:(SWTableViewCell *)cell didTriggerLeftUtilityButtonWithIndex:(NSInteger)index 

方法。