答案 0 :(得分:1)
看到这个很好的教程: Table View Animations and Gestures
演示如何使用动画更新来打开和关闭表格视图的各个部分以供查看,其中每个部分代表一个游戏,每行包含游戏的引用。它还使用手势识别器来响应用户输入:* UITapGestureRecognizer允许点击节标题以扩展该节; * UIPinchGestureRecognizer允许动态更改表视图行的高度;和*一个UILongPressGestureRecognizer,允许在表视图单元格上按住并发起引用的电子邮件。
答案 1 :(得分:0)
我遇到了类似的功能,构建它的粗略算法将是:
实施uitableviewdelgate和uitableviewdatasource协议
创建一个全局变量expandedSectionIndex = -1;
= -1表示所有已折叠。
= 0表示expandedSectionIndex。
//the following protocol definitions will take care of which section is to be expanded.
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
if(expandedSectionIndex == section)
return [self.dataArray[section] count];
else
return 0;
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
if(self.dataArray)
return [self.dataArray count];
}
在 - tableView:viewForHeaderInSection:
中定义自定义标题视图将所有按钮与选择器相关联 - (void)expand:(id)sender;
- (void)expand:(id) sender
{
expandedSectionIndex = [sender tag];
[self.tableView reload];
}