-1

I added a badge to the left of my tableViewCell as it is shown in this example. Then after getting that successfully done I moved to the next thing which is to add a swipe left/right on cell and show some options. I've successfully configured it by using this library on GitHub.

Now as I move forward I've added a cancel option on right swipe and user taps on it I want that badge (UIView) color to go Red.
I've added the green color to it as appointmentCell.appointmentStatusIndicatorBadge.layer.backgroundColor = [UIColor greenColor].CGColor; So if I call this line again in didTriggerLeftUtilityButtonWithIndex it didn't pick the appointmentStatusIndicatorBadge because it was created in PatientAppointmentTableViewCell as @property (weak, nonatomic) IBOutlet UIView *appointmentStatusIndicatorBadge; and it's being used in PatientViewController

Here is the full method where I need to access it:

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

I tried to do it by making a new object of the class but that was a stupid thing to do. The issues is now I'm unable to track the indexPath as I'm no longer inside a delegate method of TableView. So How can I do that?


EDIT
Based on a comment here is the .h code of my tableViewCell. I'm not doing anything in .h file.

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

@interface PatientAppointmentTableViewCell : SWTableViewCell
@property (weak, nonatomic) IBOutlet UIView *appointmentStatusIndicatorBadge;
@end
Borys Verebskyi
  • 4,160
  • 6
  • 28
  • 42
Chaudhry Talha
  • 7,231
  • 11
  • 67
  • 116

1 Answers1

1

Use the following code to get the indexPath of the cell:

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

Whereas, cell is the cell from following method:

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

method.

Bista
  • 7,869
  • 3
  • 27
  • 55