在使用Rg.Plugins.Popup之前,您必须调用Popup.Init()方法。

3

System.InvalidOperationException:

在使用之前,您必须调用 Rg.Plugins.Popup.Popup.Init();

我已经将 Rg.Plugins.Popup.Popup.Init() 放入 iOS 的 appdelegate.cs 中,但仍然出现相同的错误,我该怎么办?


3
请分享你的代码。在哪里以及如何调用Rg.Plugins.Popup.Popup.Init()函数? - EvZ
1个回答

5

简单来说,在启动时需要调用Rg.Plugins.Popup.Popup.Init();

安卓示例

namespace HelloXamarinFormsWorld.Android
{
    [Activity(Label = "HelloXamarinFormsWorld", MainLauncher = true,
        ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation)]
    public class MainActivity : global::Xamarin.Forms.Platform.Android.FormsApplicationActivity
    {
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            // !!!!!! here !!!!!
            Rg.Plugins.Popup.Popup.Init(this, bundle);

            Xamarin.Forms.Forms.Init(this, bundle);
            LoadApplication (new App ());
        }
    }
}

iOS示例

[Register("AppDelegate")]
public partial class AppDelegate : global::Xamarin.Forms.Platform.iOS.FormsApplicationDelegate
{
    public override bool FinishedLaunching(UIApplication app, NSDictionary options)
    {

      // !!!!!! here !!!!!
      Rg.Plugins.Popup.Popup.Init();

      global::Xamarin.Forms.Forms.Init ();
      LoadApplication (new App ());
      return base.FinishedLaunching (app, options);
    }
}

请在此处阅读文档:https://github.com/rotorgames/Rg.Plugins.Popup/wiki/Getting-started。该文档与it技术有关,如果您需要翻译,请让我知道。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接