简体   繁体   中英

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

您可能需要这样的代码来为 Type 创建一个 Class 对象:

this.RestorationClass = new ObjCRuntime.Class(typeof(BViewController));

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM