我有 UIPopoverController ,其中 DidDismiss 已连线:
popYear.PresentFromBarButtonItem(btnYear,UIPopoverArrowDirection.Any,true);
popYear.DidDismiss += (sender, args) => {
Console.WriteLine("Bye bye");
};
DidDismiss 会在用户点击popover 之外的关闭弹出窗口时触发。
但是,当弹出窗口关闭来自视图控制器时, DidDismiss 不会触发:
tbhCLose.Tapped+= () => {
if(PopOver!=null)
PopOver.Dismiss(false); //Won't cause DidDismiss to fire
};
答案 0 :(得分:1)
调用popover.Dismiss时,DidDismiss不会触发。
更好的选择是收听viewconvtroller的ViewDisappearing并在那里进行更新“
var uc = new YearViewController(SelectedYear);
uc.ViewDisappearing+= (sender, e) => {
this.SelectedYear = uc.SelectedYear;
Update();
};
popYear = new UIPopoverController(uc);
uc.PopOver = popYear;
popYear.PresentFromBarButtonItem(btnYear,UIPopoverArrowDirection.Any,true);