[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];
}