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?
Ok, I figured it out eventually. I had to move registerForPreviewingWithDelegate
to viewWillAppear
and I also had to add self.
to the beginning.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With