当前位置:编程学习 > wap >>

IOS 上拉分页刷新

[cpp] 
//放到每次刷新中(分线程和下拉刷新公用)  
iListCountNum=1; 
isEndList=NO; 

//放到每次刷新中(分线程和下拉刷新公用)
iListCountNum=1;
isEndList=NO;[cpp] view plaincopyprint?///////////////详细代码如下-- 

///////////////详细代码如下--[cpp] view plaincopyprint?- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath 

    //NSLog(@"%d",m_tieziList.count);  
    NSLog(@"%d",indexPath.row); 
    if(indexPath.row==(m_tieziList.count-1)&&isEndList==NO) 
    { 
        iListCountNum++; 
        NSLog(@"%d",indexPath.row); 
        NSThread *InitThread = [[NSThread alloc]initWithTarget:self selector:@selector(GetNewListThread:) object:tableView]; 
        [InitThread start]; 
         
         
         
    } 

-(void)GetNewListThread:(id)sender 

    NSMutableArray *array =[g_data GetTieziList:m_forumNode->forum_id pageSize:9 pageNum:iListCountNum]; 
    if(array.count == 0) 
    { 
        isEndList = YES; 
    } 
    else 
    { 
        isEndList=NO; 
    } 
    [m_tieziList addObjectsFromArray:array]; 
    [self performSelectorOnMainThread:@selector(ReLoadTableData:) withObject:(UITableView*)sender waitUntilDone:NO]; 

-(void)ReLoadTableData:(id)sender 

    UITableView *table = (UITableView*)sender; 
    [table reloadData]; 
     

- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
{
    //NSLog(@"%d",m_tieziList.count);
    NSLog(@"%d",indexPath.row);
    if(indexPath.row==(m_tieziList.count-1)&&isEndList==NO)
    {
        iListCountNum++;
        NSLog(@"%d",indexPath.row);
        NSThread *InitThread = [[NSThread alloc]initWithTarget:self selector:@selector(GetNewListThread:) object:tableView];
        [InitThread start];
       
       
       
    }
}
-(void)GetNewListThread:(id)sender
{
    NSMutableArray *array =[g_data GetTieziList:m_forumNode->forum_id pageSize:9 pageNum:iListCountNum];
    if(array.count == 0)
    {
        isEndList = YES;
    }
    else
    {
        isEndList=NO;
    }
    [m_tieziList addObjectsFromArray:array];
    [self performSelectorOnMainThread:@selector(ReLoadTableData:) withObject:(UITableView*)sender waitUntilDone:NO];
}
-(void)ReLoadTableData:(id)sender
{
    UITableView *table = (UITableView*)sender;
    [table reloadData];
   
}

 

补充:移动开发 , IOS ,
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,