Xamarin-ios在点击UiAlertController外部时将其解除

时间:2017-12-12 22:14:49

标签: ios xamarin xamarin.ios

我正在使用AlertView的第三方库。

图书馆链接在这里 - > https://github.com/kvandake/InteractiveAlert-Xamarin

我想在用户点击它时忽略AlertView,我怎么能实现这个目标?

我尝试过dissmisViewController,但它不起作用。 此外,我查看了一些旧的StackOverflow问题并尝试使用它 UITapGestureRecognizer,但它不起作用。

我的代码看起来像这样

 barItem.Clicked += delegate
            {
                InteractiveAlertView alertController = new InteractiveAlertView();
                var text = alertController
                    .AddTextField("MyAltfolio");


                var button = alertController.AddButton("Add", async () =>
                {

                    string value = text.Text;
                    var db = DatabaseManager.Instance;

                    var altfolio = await db.InsertAltfolioAsync(value);


                }, Theme.TintColor, Theme.TextColor);
                alertController
                    .ShowCustom("Altfolios", "Enter name for your altfolio", Theme
                                .TintColor, getImageWithColor(Theme.TextColor, UIImage
                                                              .FromBundle("albums.png")), "Submit", 0, UIColor
                                .Red, UIColor
                                .Purple);
            };

        }

谢谢

1 个答案:

答案 0 :(得分:1)

<强>解决

alertController.View.UserInteractionEnabled = true;
alertController.View.AddGestureRecognizer(new UITapGestureRecognizer(() => {
    alertController.HideView();
}));