2016-09-08 19 views
-1

我在我的tableViewCell的左側添加了一個徽章,如this example中所示。 然後,在成功完成之後,我轉到了下一個要在單元格上添加左/右滑動並顯示某些選項的內容。我已經在GitHub上使用this library成功配置了它。

現在,當我向前移動時,我在右側刷卡上添加了一個取消選項,用戶點擊它,我希望徽章(UIView)的顏色變爲紅色。
我已經添加了綠色,以它作爲appointmentCell.appointmentStatusIndicatorBadge.layer.backgroundColor = [UIColor greenColor].CGColor;所以,如果我在didTriggerLeftUtilityButtonWithIndex再次調用此行並沒有挑appointmentStatusIndicatorBadge,因爲它是在PatientAppointmentTableViewCell創建爲@property (weak, nonatomic) IBOutlet UIView *appointmentStatusIndicatorBadge;和它的使用在PatientViewController獲取UITableView的IndexPath來更改UIView的顏色

這裏是完整的方法,我需要訪問它:

- (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; 
    } 
} 

我試圖通過使類的一個新的對象來做到這一點,但,這是做了愚蠢的事情。現在的問題是我無法跟蹤indexPath,因爲我不再處於TableView的代理方法中。那我該怎麼做?


編輯
基於此評論是我tableViewCell的.H代碼。我在.h文件中沒有做任何事情。

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

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

你可以顯示你的表格單元類嗎? –

+0

@ Mr.UB看到我的問題的編輯版本。 –

+0

你有一個變量可以用來存儲一個標誌,看看用戶是否按下取消? –

回答

1

使用下面的代碼來獲取細胞的indexPath:

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

然而,cell是從以下方法cell

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

方法。