2011-09-27 69 views

回答

1

看到这个漂亮的教程: Table View Animations and Gestures

演示了如何使用动画更新来打开和查看,其中每个部分代表一个玩表视图的闭部分,每一行都包含来自剧中报价。它还使用手势识别器来响应用户输入:*一个UITapGestureRecognizer允许点击节头以扩展节; * UIPinchGestureRecognizer允许动态改变表格视图行的高度; * UILongPressGestureRecognizer允许按住表格视图单元以启动报价电子邮件。

+0

这正是不是教程,只是一个示例代码 – ilhnctn

0

我遇到了类似的功能,全力打造成为一个粗略的算法是:

  1. 实施uitableviewdelgate和uitableviewdatasource协议

  2. 创建一个全局变量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)展开:(id)sender;

      - (void)expand:(id) sender 
      { 
          expandedSectionIndex = [sender tag]; 
          [self.tableView reload]; 
      } 
      

      更多细节enter link description here