iOS9でReloadSectionsを実行するとcontentOffsetがゼロになる?
現在 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のバグなのか、仕様なのか
また、トップに行かせずに位置の固定ができるかを教えて下さい。
Author And Source
この問題について(iOS9でReloadSectionsを実行するとcontentOffsetがゼロになる?), 我々は、より多くの情報をここで見つけました https://qiita.com/maedahiroya/items/40a3f9a9a7f0f33e1bc5著者帰属:元の著者の情報は、元のURLに含まれています。著作権は原作者に属する。
Content is automatically searched and collected through network algorithms . If there is a violation . Please contact us . We will adjust (correct author information ,or delete content ) as soon as possible .