I want to access a button of a section header when user clicks on row in tableview
. I can get clicked row number and that particular section by using NSIndexpath
(i.e. section 1 - row 0 etc.), but could not retrieve button in the section header. I've tried using isKindOfClass
by iterate through tableview
, but did not work.
MainTableViewCell *clickedResourceCell = (MainTableViewCell*)btn.superview.superview;
clickedResourceCell.customThresholdBar.value = slider.value/100;
NSIndexPath *indexpath = [self.tableView indexPathForCell:clickedResourceCell];
[btn setTitle:[NSString stringWithFormat:@"%i%@", [[NSNumber numberWithFloat:[(UISlider *)sender value]] intValue], @"%"] forState:UIControlStateNormal];
self.sliderValueLabel.text = [NSString stringWithFormat:@"%i%@", [[NSNumber numberWithFloat:[(UISlider *)sender value]] intValue], @"%"];
I've got row's button updated.Now want to update section.I've tried like this!
for(UIView *view in [self.tableView subviews])
{
if([view isKindOfClass:[UIButton class]])
{
UIButton *bttn = (UIButton *)view;
if (bttn.titleLabel.tag == 7) {
if (bttn.tag == indexpath.section) {
NSLog(@"FOUND");
[bttn setTitle:[NSString stringWithFormat:@"%i%@", completedAmount/i, @"%"] forState:UIControlStateNormal];
}
}
}
}