有一個UIPopoverController,有DidDismiss
popYear.PresentFromBarButtonItem(btnYear,UIPopoverArrowDirection.Any,true);
popYear.DidDismiss += (sender, args) => {
Console.WriteLine("Bye bye");
};
如果popover被用戶關閉,DidDismiss就觸發正常。
如果popover通過viewcontroller關閉,DidDismiss就不能正常觸發。
tbhCLose.Tapped+= () => {
if(PopOver!=null)
PopOver.Dismiss(false); //Won't cause DidDismiss to fire
};
如果調用了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);