你好,歡迎來到IOS教程網

 Ios教程網 >> IOS訊息 >> 關於IOS >> IOS 上拉分頁刷新

IOS 上拉分頁刷新

編輯:關於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];
   
}

 

  1. 上一頁:
  2. 下一頁:
蘋果刷機越獄教程| IOS教程問題解答| IOS技巧綜合| IOS7技巧| IOS8教程
Copyright © Ios教程網 All Rights Reserved