Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/35.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone UITableView节在ViewForHeader节中单击_Iphone_Uitableview_Uibutton - Fatal编程技术网

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
}