【问题标题】:How do I set a RestorationClass in a Xamarin.iOS UIViewController without storyboards?如何在没有情节提要的 Xamarin.iOS UIViewController 中设置 RestorationClass?
【发布时间】:2016-09-07 00:04:05
【问题描述】:

tutorials like this,我知道我需要在我的视图控制器上设置RestorationIdentifierRestorationClass,以便在没有情节提要的情况下恢复状态,但我不知道如何设置@ 987654325@ 在我的视图控制器中。

Objective-C 示例执行 self.RestorationClass = [self class],但我尝试的 C# 翻译 RestorationClass = this 产生错误无法将类型 Foo 隐式转换为 ObjCRuntime.Class。如何解决此错误?

Repo with my working, minimal example

【问题讨论】:

  • 您还有示例项目吗?我知道如何调用 RestorationClass,但我不知道其余的。

标签: c# ios uiviewcontroller xamarin.ios


【解决方案1】:

您可能希望这样的代码为 Type 创建一个 Class 对象:

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

【讨论】:

    猜你喜欢
    • 2013-05-11
    • 2013-02-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-06-28
    • 1970-01-01
    相关资源
    最近更新 更多