我正在为 AlertView 使用第三方库。
图书馆链接在这里 -> https://github.com/kvandake/InteractiveAlert-Xamarin
当用户在 AlertView 外部单击时,我想关闭 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);
};
}
谢谢
最佳答案
已解决
alertController.View.UserInteractionEnabled = true;
alertController.View.AddGestureRecognizer(new UITapGestureRecognizer(() => {
alertController.HideView();
}));
关于ios - Xamarin-ios 在 UiAlertController 外部单击时关闭它,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47782408/