2013-10-30 25 views
0

我有100個記錄要加載在UITableview中,最初我只是想重新加載前25條記錄,而當我們在25條記錄後滾動tableview時,table想重新加載下面的25條記錄,就像我想爲ios中的所有記錄做的那樣。我怎樣才能做到這一點?有人幫助我?如何在UITableview中滾動時拆分數據並重新加載?

+1

哪裏有記錄從未來它會載入你的數據?如果你在本地擁有所有的數據,那麼完全沒有理由這樣做。 – rmaddy

+0

UITableView將爲只有可見的單元格創建單元格實例,剩下的單元格會一旦向上或向下滾動就會出列。所以不需要像你想要的那樣做。 – Vedchi

回答

1

聲明row_count爲int。在viewDidLoad設置row_count = 25;,然後通過numberOfRowsInSection取代return row_count;然後return [table_array count];我的代碼添加我的方法scrollViewDidScroll

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section 
    { 
     return row_count; 
    } 

- (void)scrollViewDidScroll:(UIScrollView *)aScrollView { 
     CGPoint offset = aScrollView.contentOffset; 
     CGRect bounds = aScrollView.bounds; 
     CGSize size = aScrollView.contentSize; 
     NSLog(@"%@", NSStringFromCGSize(size)); 
     UIEdgeInsets inset = aScrollView.contentInset; 
     float y = offset.y + bounds.size.height - inset.bottom; 
     float h = size.height; 
      float reload_distance = 10; 
     if(y > h + reload_distance) { 
      row_count = (row_count + 25 > [table_array count])?[table_array count]:row_count + 25;   
      [Yourtable reloadData]; 
     } 
    } 

設置這樣的..只要你想

相關問題