简体   繁体   中英

UITableView Content Offset Increasing Unexpectedly

I have a UITableView embedded in a navigation controller. When i segue from the TableView onto the next screen, i store the offset such that if i press the 'back' button, the offset on the original view remains the same, and it doesnt scroll up to the top.

var tableViewContentOffset = CGPointMake(0.0, 0.0)

override func viewWillAppear(animated: Bool) {
    super.viewDidAppear(animated)
    tableView.contentOffset = tableViewContentOffset
}

override func viewWillDisappear(animated: Bool) {
    super.viewDidDisappear(animated)
    tableViewContentOffset = tableView.contentOffset
}

This works perfectly when the view loads the first time, however each time i move onto the next screen and then return, the offset is increased by y(-64.0) What is causing this? First time loaded:

After Segueing and returning once:

您可以automaticallyAdjustScrollViewInsetsfalse设置为false

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM