Using protocol Delegate method
Code for custom cell .h file
#import <UIKit/UIKit.h>
@protocol CustomCellProtocal <NSObject>
-(void)CellButtonClicked:(UIButton *)sender;
@end
@interface CustomCell : UITableViewCell
@property(weak) id<CustomCellProtocal>delegate;
- (IBAction)BtnClicked:(id)sender;
@end
code for custom cell .m file
#import "CustomCell.h"
@implementation CustomCell
@synthesize delegate;
- (IBAction)BtnClicked:(id)sender {
[delegate CellButtonClicked:sender];
}
@end
Another simplest way
I suggest you to create custom cell having Button. Create outlet for that button in custom cell class.
Then in cellForRowAtIndexpath() add target to that button like follow
[CustomCell.buttonOutlet addTarget:self action:@selector(BtnClicked:) forControlEvents:UIControlEventTouchUpInside];
Then handle your logic in BtnClicked method.
-(void)BtnClicked:(UIButton *)sender{
if(sender.tag == 1){
[sender setTitle:@"Hello" forState:UIControlStateNormal];
}
}
I strongly suggest, second way is best for your case. And cell will be dequed with identifier. so no need to worry.