【问题标题】:Is it possible to reload UITableView except particular rows of section?除了部分的特定行之外,是否可以重新加载 UITableView?
【发布时间】:2017-08-09 07:22:30
【问题描述】:

我正在尝试重新加载UITableView 中的特定section,但它无法正常工作意味着所有sections 都在重新加载。如何解决这个问题

代码:

UIView.performWithoutAnimation({ 
  let loc = self.cartTbl.contentOffset 
  self.cartTbl.reloadSections(IndexSet(integer: sender.tag), with: .middle);
  self.cartTbl.contentOffset = loc 
}) 

这里sender.tag 表示点击按钮时正在传递节号

【问题讨论】:

  • 在这里显示一些代码
  • UIView.performWithoutAnimation({ let loc = self.cartTbl.contentOffset self.cartTbl.reloadSections(IndexSet(integer: sender.tag), with: .middle); self.cartTbl.contentOffset = loc } ) 这里 sender.tag 表示在按钮单击时传递部分编号
  • 使用reloadRowsAtIndexPaths:withAnimation:

标签: ios uitableview swift3


【解决方案1】:
let sectionIndex = 1
let set: IndexSet = [sectionIndex]
self.tableView.reloadSections(set, with: .automatic)

您可以使用表格视图的重新加载部分方法。

【讨论】:

    【解决方案2】:

    您是否使用reloadSections 方法来更新特定部分?使用reloadSections 方法,您可以重新加载特定部分,而无需重新加载表格的其他部分。

    https://developer.apple.com/documentation/uikit/uitableview/1614954-reloadsections?language=objc

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-08-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-07-11
      • 1970-01-01
      相关资源
      最近更新 更多