0

我有一个视图让用户编辑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);
        }

任何帮助表示赞赏!

4

1 回答 1

4

由于您将视图控制器推送到导航堆栈上,因此您可以通过将其从堆栈中弹出来将其关闭。 UINavigationController具有三个 POP 方法

  • PopToRootViewController - goes all the way back to the root view of your navigation controller
  • PopToViewController - pops back to a specific view controller
  • PopViewController - pops back to the "previous" view controller
于 2013-02-15T00:43:19.013 回答