Sasha Fahrenkopf Sasha Fahrenkopf - 1 year ago 102
iOS Question

How do I set a RestorationClass in a Xamarin.iOS UIViewController without storyboards?

From tutorials like this, I know that I need to set the RestorationIdentifier and RestorationClass on my view controllers in order to get state restoration to work without storyboards, but I can't figure out how to set the RestorationClass in my view controller.

Objective-C examples do

self.RestorationClass = [self class]
, but my attempted C# translation
RestorationClass = this
produces the error Cannot implicitly convert type 'Foo' to 'ObjCRuntime.Class. How do I work around this error?

Repo with my working, minimal example

Answer Source

You would want code like this to create a Class object for the Type:

this.RestorationClass = new ObjCRuntime.Class(typeof(BViewController));
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download