Issues with 3D Touch and state restoration
Asked Answered
M

1

10

I am working on implementing state restoration into my app, however I have ran into an issue. I recently added 3D Touch support to the table view, and it worked perfectly every time except now that I have added state restoration. When the app restores the table view, applying pressure to the cells does nothing, as if the table view hasn't been registered for previewing.

I have this code in viewDidLoad:

override func viewDidLoad() {
    super.viewDidLoad()

    if #available(iOS 9.0, *) {
        if traitCollection.forceTouchCapability == UIForceTouchCapability.Available {
            registerForPreviewingWithDelegate(self, sourceView: view)
        }
    }
}

I tried moving it to viewDidAppear to see if it would help, but it didn't make a difference.

Any ideas?

Maimonides answered 28/9, 2015 at 14:21 Comment(0)
M
4

Ok, I figured it out eventually. I had to move registerForPreviewingWithDelegate to viewWillAppear and I also had to add self. to the beginning.

Maimonides answered 1/10, 2015 at 18:14 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.