当tableView.reloadRowsAtIndexPaths更改了contentoffset时

时间:2015-12-14 04:41:49

标签: ios swift

在我的自定义UITableViewController中,viewDidLoad()我设置了tableView.estimatedRowHeight = 300tableView.rowHeight = UITableViewAutomaticDimension 然后当我调用tableView.reloadRowsAtIndexPaths时,contentoffset发生了变化,我该如何解决?谢谢!

tableView.estimatedRowHeight = 300
tableView.rowHeight = UITableViewAutomaticDimension
tableView.registerNib(UINib(nibName:"PostCell", bundle: nil), forCellReuseIdentifier: "PostCell")
tableView.registerClass(UITableViewCell.self, forCellReuseIdentifier: "PunchCardCell")

func handlePostChange(notification: NSNotification) {
    if let object = notification.object as? Post {
        for (index, post) in posts.enumerate() {
            if post.objectId == object.objectId {
                if let userInfo = notification.userInfo {
                    post.setValuesForKeysWithDictionary(userInfo as! [String : AnyObject])
                }
                let indexPath = NSIndexPath(forRow: index, inSection: 0)
                tableView.reloadRowsAtIndexPaths([indexPath], withRowAnimation: .None)
                break
            }
        }
    }
}

0 个答案:

没有答案
相关问题