gpt4 book ai didi

ios - 在页 footer 分创建按钮并检测正确的点击

转载 作者:行者123 更新时间:2023-11-28 22:15:29 28 4
gpt4 key购买 nike

我有一个带有按钮的节页脚,但我不知道如何检测在我的 TableView 中单击了哪个节页脚。我知道我必须使用“标签”之类的东西,但如何使用?

-(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"]];

感谢您的宝贵时间!

最佳答案

您将发件人转换为按钮并阅读标签:

- (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"]];
}

希望这对您有所帮助。

关于ios - 在页 footer 分创建按钮并检测正确的点击,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21835439/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com