Bug 8778 - UIViewControllerRestoration Protocol is not bound
Summary: UIViewControllerRestoration Protocol is not bound
Alias: None
Product: iOS
Classification: Xamarin
Component: Xamarin.iOS.dll ()
Version: 6.0.x
Hardware: Macintosh Mac OS
: --- major
Target Milestone: Untriaged
Assignee: Bugzilla
Depends on:
Reported: 2012-12-05 13:27 UTC by Mike Bluestein
Modified: 2013-02-12 01:10 UTC (History)
3 users (show)

Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.

Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:

Description Mike Bluestein 2012-12-05 13:27:37 UTC
This protocol is used when creating restoration classes as part of the new iOS 6 state preservation.
Comment 1 Miguel de Icaza [MSFT] 2013-02-12 00:55:50 UTC
That is because it is not possible to provide a meaningful binding for it.

The way to implement this, is to add the following static member:

[Adopts ("UIViewControllerRestoration")]
class MyUIViewController : UIViewController {

  [Export ("viewControllerWithRestorationIdentifierPath:")]
  static UIViewController FromIdentifierPath (string [] path, NSCoder coder)
    // Implement your restoation here

Do you have a sample to point me to, to see hwat you were trying to implement?
Comment 2 Miguel de Icaza [MSFT] 2013-02-12 01:08:40 UTC
I added this to our API docs for UIViewController:

+        <h2>State Restoration</h2>
+      </format>
+      <para>
+       If you want to provide state restoration in your class, you
+       need to manually add a method with the following signature to
+       your class:
+      </para>
+<code lang="c#">
+[Adopts ("UIViewControllerRestoration")]
+class MyUIViewController : UIViewController {
+  [Export ("viewControllerWithRestorationIdentifierPath:")]
+  static UIViewController FromIdentifierPath (string [] identifierComponents, NSCoder coder)
+  {
+     var sb = (UIStoryboard) coder.DecodeObject (UIStateRestoration.ViewControllerStoryboardKey);
+     if (sb != null){
+      var vc = (MyUIViewController) sb.InstantiateViewController ("MyViewController");
+      vc.RestorationIdentifier = identifierComponents [identifierComponents.Length-1];
+      vc.RestorationClass = Class.GetHandle (typeof (MyViewController));
+     }
+  }
Comment 3 Miguel de Icaza [MSFT] 2013-02-12 01:10:33 UTC
Set proper bug resolution.