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

Him*_*shu 2 .net c# popupwindow visual-studio xamarin.forms

System.InvalidOperationException:

你必须调用 Rg.Plugins.Popup.Popup.Init(); 在使用它之前。

我已经把 Rg.Plugins.Popup.Popup.Init() 放在 IOS 的 appdelegate.cs 中

但它仍然给我同样的错误我应该怎么做?

AAA*_*ddd 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 ());
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

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);
    }
}
Run Code Online (Sandbox Code Playgroud)

请阅读此处的文档

https://github.com/rotorgames/Rg.Plugins.Popup/wiki/Getting-started