Iphone UITableView节在ViewForHeader节中单击
我在Iphone UITableView节在ViewForHeader节中单击,iphone,uitableview,uibutton,Iphone,Uitableview,Uibutton,我在UITableViewviewForHeaderInSection中创建了一个自定义ui按钮。现在,当我单击该部分中的按钮时,我如何知道单击了哪个部分?请帮忙 在didselectrowatindexpath中检查(索引路径.section)是否等于要执行操作的节。当您在视图中添加按钮以查看标题节时,只需设置带有节号的标记,如下图所示 button.tag = section; 当你按下按钮的时候,你可以用下面的代码得到那个号码 - (IBAction)yourButton_Clicked
UITableView
viewForHeaderInSection
中创建了一个自定义ui按钮。现在,当我单击该部分中的按钮时,我如何知道单击了哪个部分?请帮忙 在didselectrowatindexpath中检查(索引路径.section)是否等于要执行操作的节。当您在视图中添加按钮以查看标题节时,只需设置带有节号的标记,如下图所示
button.tag = section;
当你按下按钮的时候,你可以用下面的代码得到那个号码
- (IBAction)yourButton_Clicked:(id) sender
{
NSLog(@"Section Number => %d",[sender tag]);
}
通过此操作,您可以访问btn并在该burron上添加事件按钮是静态还是动态?OP所说的是表格单元格中的自定义UIButton,不是表格单元格本身你可以检查该部分,你可以改变单元格。在评论bro之前尝试一下。每个部分都有一个UIButton,当我单击按钮时,我需要知道单击了哪个部分,以便我可以只展开该部分的行
-(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
UIbutton *button =[[UIButton alloc]init];
button.tag=section;// this tag property will differentiate button for different section
}
-(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
UIbutton *btn =[[UIButton alloc]init];
btn.tag=section;// this tag property will differentiate button for different section
}