實現tableview的下拉重新整理,tableview下拉重新整理

來源:互聯網
上載者:User

實現tableview的下拉重新整理,tableview下拉重新整理
實現tableview的下拉重新整理
 推薦第三方下拉重新整理代碼http://code4app.com/ios/%E5%BF%AB%E9%80%9F%E9%9B%86%E6%88%90%E4%B8%8B%E6%8B%89%E4%B8%8A%E6%8B%89%E5%88%B7%E6%96%B0/52326ce26803fabc46000000
 tableview滑動就會觸發這個方法?

-(void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath { //當tableview下拉到最後一行的時候才觸發 if (indexPath.row == self.m_data.count - 1) {  //定義一個UIViewUIView *footSpinnerView = [[UIView alloc] initWithFrame:CGRectMake(0.0f, 0.0f, 320.0f, 60.0f)];//頂一個有重新整理表徵圖的view UIActivityIndicatorView *activity = [[UIActivityIndicatorView alloc] initWithFrame:CGRectMake(130.0f, 0.0f, 60.0f, 60.0f)];activity.color = [UIColor redColor];[activity startAnimating];//啟動有重新整理表徵圖的view  footSpinnerView.backgroundColor = [UIColor grayColor];[footSpinnerView addSubview:activity]; //設定footerview self.myTableView.tableFooterView = footSpinnerView; // self.myTableView.tableHeaderView = footSpinnerView;  dispatch_queue_t queue = dispatch_queue_create("my queue", nil);  //在後台線程添加資料dispatch_async(queue, ^(void){ [self.m_data addObject:@"1000"]; [self.m_data addObject:@"1001"]; [self.m_data addObject:@"1002"]; [self.m_data addObject:@"1003"]; [self.m_data addObject:@"1004"];  });  //添加完資料就重新載入資料 dispatch_async(queue, ^(void) {  sleep(2); dispatch_sync(dispatch_get_main_queue(), ^(void){  [self.myTableView reloadData]; }); });  // [self.myTableView reloadData]; dispatch_release(queue); [footSpinnerView release]; [activity release]; } }

  

 

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.