我目前正在创建一个具有可扩展/可折叠部分的UitableView。

我以JSON格式从Internet获取数据,将其存储在像这样的数组中:

{第1节{S1数据1,S1数据2,...},第2节{S2数据1,S2数据2,等等}}

部分可以是字母内的字母,年号或其他。

我这样创建了我的表观视图标题:

GTHeaderView *header = [GTHeaderView headerViewWithTitle:[NSString stringWithFormat:@"%@", myArray.SectionValue]];
[header.button addTarget:self action:@selector(toggleSection) forControlEvents:UIControlEventTouchUpInside];

这很好,但是在我的“切换”方法中,我找不到一种了解巫婆部分的方法,以折叠/扩展。

我知道我无法在选择器中发送参数...那么您认为哪种解决方案适合我的需求?

提前致谢 !

有帮助吗?

解决方案

你可以写你的 toggleSection 方法为:

- (void)toggleSection:(id)sender
{
   // send the sender object a message to find out the section number here...
}

当然要改变你的 addTarget 行以指定 toggleSection 方法现在有一个参数:

[header.button addTarget:self action:@selector(toggleSection:) forControlEvents:UIControlEventTouchUpInside];
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top