经过一番尝试和错误后,我得到了解决方案......我希望其他人能从我的解决方案中受益;)
在我的基本观点中:
public override void PrepareForSegue (UIStoryboardSegue segue, NSObject sender)
{
if (segue.Identifier == "MySegueIdentifier")
{
var popoverSegue = segue as UIStoryboardPopoverSegue;
_myTableViewController = segue.DestinationViewController.ChildViewControllers[0] as MyTableViewController;
_myTableViewController.PopoverController = popoverSegue.PopoverController;
_myTableViewController.CloseCallback = AddNewTrAndRefreshCallback;
}
base.PrepareForSegue (segue, sender);
}
private void AddNewTrAndRefreshCallback()
{
if (myTableViewController == null || _myTableViewController.Cancled)
return;
var selectedRecord = _myTableViewController.SelectedRecord;
// Do whatever you want...
}
在我的弹出窗口中(嵌入在 UINavigationViewController 中的 UITableViewController)
partial void buttonCancelClicked (MonoTouch.UIKit.UIBarButtonItem sender)
{
Cancled = true;
CloseCallback();
PopoverController.Dismiss(true);
}
partial void buttonDoneClicked (MonoTouch.UIKit.UIBarButtonItem sender)
{
Cancled = false;
SelectedRecord = _tableViewSource.SelectedRecord;
CloseCallback();
PopoverController.Dismiss(true);
}
不要犹豫,问是否有任何不确定。