2016-03-18 59 views
0

我在tableview中有4個部分。 我使用重裝部分:在ios中重新加載UITableView的部分

[self.tableview reloadSections:[NSIndexSet indexSetWithIndex:1] withRowAnimation:UITableViewRowAnimationNone]; 

會發生什麼事,當我在第2觀察細胞和我的代碼運行重裝第1節; tableView位置起來。 我希望tableview的位置被維護,當表中的任何部分重新加載。同時,我不希望tableview的任何動畫,當表重新加載時。 謝謝!

+0

如果你的表是重裝後段滾動,只需使用行動畫「UITableViewRowAnimationNone」與reloadSections方法。 – Shardul

+0

@Shardul:我只使用同一行的動畫;但它仍然具有動畫效果。 – Saggy

+0

我得到了解決方案,因爲我使用單元大小的tableviewCells,我需要實現estimatedRowHeight()委託方法。並且需要指定約。每個部分的細胞高度。這有助於我解決這個問題。 – Saggy

回答

0

嘗試下面的代碼:

 [self.tableView beginUpdates]; 

      NSRange range = NSMakeRange(0, 1);//Your section number instead of 1 
      NSIndexSet *section = [NSIndexSet indexSetWithIndexesInRange:range]; 
      [self.tableView reloadSections:section withRowAnimation:UITableViewRowAnimationNone]; 

     [self.tableView endUpdates]; 
+0

仍然無法正常工作。表重新加載時,表格中的位置和動畫也在那裏。 – Saggy

+0

嘗試使用'dispatch_async(dispatch_get_main_queue(),^ {});'block –

0
- (void)reloadSections:(NSIndexSet *)sections withRowAnimation:(UITableViewRowAnimation)animation