没有人用过tableFooterView吗?或者这样的功能(tableView移动到最后一行会添加刷新数据,就是新浪微博那个效果)有没有其他方法可以实现?求高手!!

解决方案 »

  1.   

    这个是这样实现的:
    首先,UITableView 的父视图是 UIScrollView。
    然后,在 FooterView 中添加一个 UIView,
    并记住 offset(在 UIScrollView 中的),
    当滑动点超过这个 offset 时,
    去服务器取数据,
    添加到数据源中。
      

  2.   

    用UITableViewDelegate中的这个方法:
    - (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath;判定tableView中的数组数是否即将显示最后一个cell,if (indexPath.row == [self.dataArr count]-1) 如果是的话,self.tableView.tableFooterView = footSpinnerView;//footSpinnerView为自定义的UIView,上面加了一个旋转的UIActivityIndicatorView即可,记得让UIActivityIndicatorView  startAnimation加上你关于刷新数组的逻辑,如从数据库中取出更多的数据,取完数据后,将self.tableView.tableFooterView设nil即可。
    Demo:#pragma  -
    #pragma  UITableViewDelegate
    - (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
    {
        if (indexPath.row == [self.productArr count]-1) {
            
            [self setupFootSpinnerView];
            
            self.tableView.tableFooterView = footSpinnerView;
            
            if (currentArrCount < dataCount) {
                currentArrCount += 5;
             
                self.dataArr =  [dao getArrayOfDataLimit:currentArrCount offset:0];//从数据库中重新取数据
                [self.tableView reloadData];        }else{
                self.tableView.tableFooterView = nil;
            
            }
            
            
        }}