I have created a custom View and added it to the tableView section header.
func tableView(tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
if section == 2 {
if (headerView == nil) {
headerView = CustomHeaderSection(frame: CGRectMake(0,0,self.view.bounds.width,38))
}
headerView!.delegate = self
if isExpandableCell {
headerView!.arrowImage.transform = CGAffineTransformIdentity
}else {
headerView!.arrowImage.transform = CGAffineTransformMakeRotation(CGFloat(M_PI))
}
return headerView
}
return nil
}
I have a button on the custom view that I have added on the tableview section. Now how will I get the indexPath when I click on it?
Declare a section number variable in CustomHeader class and assign its value while instantiating inside viewForHeaderInSection().
Implement the target button action inside the same class. So, on tap get self.section and pass it to ViewController.
void onButtonTap (id sender)
{
UIButton button = (UIButton)sender;
this.sectionHeaderViewDelegate.buttonTapped (this.section);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With