System.InvalidOperationException:
你必须调用Rg.Plugins.Popup.Popup.Init();在使用之前。
我已经在IOS的appdelegate.cs中放了Rg.Plugins.Popup.Popup.Init()
但它仍然给我同样的错误 我该怎么办呢?
答案 0 :(得分:2)
简单地说,您需要在启动时调用Rg.Plugins.Popup.Popup.Init();
Andriod示例
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