LoginSignup
0
1

More than 5 years have passed since last update.

iOS9でReloadSectionsを実行するとcontentOffsetがゼロになる?

Last updated at Posted at 2018-11-06

現在 iOS9以上で動くアプリを作成していて、詰まりました。
reloadSectionsを実行した際に
iOS10以上は現在の位置そのまま表示されるのですが、
iOS9だと、シミュレータ、実機共に
TableViewのいちばん上まで戻ってしまいます。

if #available(iOS 10.0, *) {
  debugLog("iOS10以上")
  self.mainTableView.reloadSections(self.SectionIndex, with: UITableViewRowAnimation.automatic)
} else {
  debugLog("iOS9以下")
  self.mainTableView.beginUpdates()
  let nowOffset = self.mainTableView.contentOffset
  self.mainTableView.reloadSections(self.SectionIndex, with: UITableViewRowAnimation.automatic)
  self.mainTableView.endUpdates()
  self.mainTableView.setContentOffset(nowOffset, animated: true)
}

現在は上記のような形です。

更新後に上に行ってしまうのは、Xcode,iOSのバグなのか、仕様なのか
また、トップに行かせずに位置の固定ができるかを教えて下さい。

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1