i have an Section Footer with an Button in it, but i dont know how to detect which section footer is clicked in my TableView. I know i have to use something like "tag", but how?
-(UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section{
self.footerHeartView = [[UIView alloc]initWithFrame:CGRectMake(10, 0, 300, 60)];
[self.footerHeartView addSubview:viewFotter];
UIView *viewFotter = [[UIView alloc]initWithFrame:CGRectMake(10, 0, 300, 60)];
self.heartButton = [[UIButton alloc]initWithFrame:CGRectMake(200, 5, 70, 50)];
self.heartButton.tag = section;
self.heartButton.backgroundColor = [UIColor greenColor];
[self.heartButton addTarget:self
action:@selector(heartClick:)
forControlEvents:UIControlEventTouchUpInside];
[viewFotter addSubview:self.heartButton];
[viewFotter setBackgroundColor:[UIColor whiteColor]];
return self.footerHeartView;
}
- (void)heartClick:(UIButton*)sender {
NSLog(@"CLICK");
[[GTAppController sharedInstance].api sendLike:1 itemId:[[self.newsList objectAtIndex:???????]objectForKey:@"testId"]];
}
Thanks for your Time!
You cast sender as a button and read tag:
- (void)heartClick:(UIButton*)sender {
NSLog(@"CLICK");
UIButton* sectionButton = (UIButton*)sender;
int section = sectionButton.tag;
[[GTAppController sharedInstance].api sendLike:1 itemId:[[self.newsList objectAtIndex:???????]objectForKey:@"testId"]];
}
Hope this help.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.