我有一个视图,我让用户编辑EntryElement
。我通过“完成”按钮的委托来注册点击事件,但是我不能让它解除当前视图以转到上一个视图。这就是我现在正在尝试的事情:
AppDelegate.navigation.PresentedViewController.DismissViewController(true, null);
我也试过了:
AppDelegate.navigation.PresentedViewController.RemoveFromParentViewController();
navigation
只是UINavigationController
编辑:
我正在使用Monotouch.Dialog
来构建所有视图。此视图是通过方法创建的。我希望它们在单击完成按钮后返回上一个视图。这是方法的内容:
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);
}
感谢任何帮助!
答案 0 :(得分:4)
由于您将视图控制器推到导航堆栈上,因此通过将其从堆栈中弹出来解除它。 UINavigationController有三种POP方法