c# - 你必须调用 Rg.Plugins.Popup.Popup.Init();使用前

标签 c# .net visual-studio xamarin.forms popupwindow

System.InvalidOperationException:

You MUST call Rg.Plugins.Popup.Popup.Init(); prior to using it.

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

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

最佳答案

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

Android 示例

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

关于c# - 你必须调用 Rg.Plugins.Popup.Popup.Init();使用前,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50795975/

相关文章:

c# - if 语句中的空条件 boolean 值

c# - 如何使用 SqlBulkCopyColumnMappingCollection?

.net - 何时使用 Using 语句

.net - 如何将自定义默认生成操作关联到 Visual Studio 中的自定义文件类型?

visual-studio - 如何安装适用于 Visual Studio 2015 的旧版本 "SQLite for Universal Windows Platform"SDK?

c# 没有向 PHP 发送 json 请求

c# - 在 XmlNodeList 上使用 LINQ

c++ - VS2013 : fatal error C1001: An internal error has occurred in the compiler

c# - 在 C# 中验证数字签名

c# - 枚举上最常见的 C# 按位运算