【问题标题】:PerformSegue proper callPerformSegue 正确调用
【发布时间】:2013-04-03 16:50:38
【问题描述】:

Xamarin/MonoTouch 新手

我有一个通用故事板应用程序(ipad 和 iphone) 我使用故事板

所以我已经从 MainViewController 链接了一个 segue 到secondaryViewController (educateViewController)。

我不使用也不想使用导航控制器(我可以在原生 iOS 中做到这一点)

我正在为 PerformSegue 调用而苦苦挣扎,导致

System.Exception:从托管对象 c 调用的选择器 MyTestApp.educateViewController (0x9827E50) 类型的对象 已被 GC ---> System.Exception: No constructor found for MyTestApp.educateViewController::.ctor(System.IntPtr)

我有 私人教育视图控制器教育屏幕;

在 ViewDidLoad() 内部 教育屏幕 = 新的教育视图控制器();

partial void educate (MonoTouch.Foundation.NSObject sender)
        {
            solveIt(sender);

            if (valid) {
                if (UserInterfaceIdiomIsPhone) {
                    this.PerformSegue("educate", this);  <<<< error occurs here
                } else if (UserInterfaceIdiomIsiPad) {
                    this.Instructor.Hidden = false;
                }
            }
        }

只有在 iPhone 上才能调用 Segue

欢迎大家帮忙,提前致谢

【问题讨论】:

    标签: xamarin.ios xamarin


    【解决方案1】:

    您需要确保 EducateViewController 实现了以下构造函数:

    public EducateViewController (IntPtr handle) : base (handle)
    {
    }
    

    这应该允许从情节提要中实例化视图控制器。

    【讨论】:

      【解决方案2】:

      执行转场:

      this.PerformSegue("segueIdentifier here", this);
      

      在目标类上,添加:

      protected MyCustomController(IntPtr handle) : base(handle)
              {
                  // Note: this .ctor should not contain any initialization logic.
              }
      

      注意:请将“MyCustomController”更改为您的目标控制器名称。

      【讨论】:

        猜你喜欢
        • 2013-08-30
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2019-06-21
        • 1970-01-01
        • 1970-01-01
        • 2017-03-22
        • 1970-01-01
        相关资源
        最近更新 更多