我有一个让用户编辑 EntryElement
的 View 。我通过“完成”按钮的委托(delegate)很好地注册了点击事件,但是我无法让它关闭当前 View 以转到上一个 View 。这是我现在正在尝试的:
AppDelegate.navigation.PresentedViewController.DismissViewController(true, null);
我也试过:
AppDelegate.navigation.PresentedViewController.RemoveFromParentViewController();
navigation
只是一个 UINavigationController
编辑:
我正在使用 Monotouch.Dialog
构建所有 View 。这个 View 是通过一个方法创建的。一旦他们单击完成按钮,我希望它返回到以前的 View 。以下是方法的内容:
public static void EditClientTypeView (string typeName, string typeId)
{
DialogViewController editClientTypeVC;
UIBarButtonItem doneButton = new UIBarButtonItem (UIBarButtonSystemItem.Done);
EntryElement element = new EntryElement("Type Name", "Name of client type", typeName, false);
var root = new RootElement ("Edit Type") {
new Section () {
element
}
};
editClientTypeVC = new DialogViewController (root, true);
editClientTypeVC.NavigationItem.RightBarButtonItem = doneButton;
doneButton.Clicked += (sender, e) => {
// Need to save the edited client type to the database
Console.WriteLine("Done button clicked signifying the user is finished editing");
AppDelegate.navigation.PresentedViewController.RemoveFromParentViewController();
//AppDelegate.navigation.DismissViewController(true, null);
};
AppDelegate.navigation.PushViewController(editClientTypeVC, true);
}
感谢任何帮助!
最佳答案
由于您将 View Controller 推送到导航堆栈,因此您可以通过将其弹出堆栈来关闭它。 UINavigationController具有三种POP方法
- PopToRootViewController - 一直返回到导航 Controller 的 Root View
- PopToViewController - 弹回到特定的 View Controller
- PopViewController - 弹回“上一个” View Controller
关于ios - Monotouch - 无法在单击按钮时关闭当前 View ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14886209/