I have two custom UItableViewCell
with Same UIButton
, How to determine from Which Cell UIButton
is called ?
P.S. I Don’t want To use two different methods.
cellForRowAtIndexPath Method.
if (indexPath.row==1) {
static NSString *cellIdentifier = @“CustomeCell1“;
NewsFeedCell1 *cell = (NewsFeedCell1 *)[tableView dequeueReusableCellWithIdentifier:cellIdentifier];
cell.btnPrivacy.tag = indexPath.row;
[cell.btnPrivacy addTarget:self action:@selector(btnPrivacyClicked:) forControlEvents:UIControlEventTouchUpInside];
}
else
{
static NSString *cellIdentifier = @"CustomeCell2”;
NewsFeedCell2 *cell = (NewsFeedCell2 *)[tableView dequeueReusableCellWithIdentifier:cellIdentifier];
cell.btnPrivacy.tag = indexPath.row;
[cell.btnPrivacy addTarget:self action:@selector(btnPrivacyClicked:) forControlEvents:UIControlEventTouchUpInside];
}
Button click Methods.
-(IBAction)btnPrivacyClicked:(UIButton *)sender
{
NSLog(@"Privacy Clicked at : %ld",(long)sender.tag);
// Here Determine From Which Cell UiButton Is Clicked.
NewsFeedCell1 *cell = (NewsFeedCell1 *)[self.HomeTable cellForRowAtIndexPath:[NSIndexPath indexPathForRow:sender.tag inSection:0]];