在iOS单声道触摸中关闭视图控制器

时间:2014-02-04 07:09:23

标签: uinavigationcontroller xamarin.ios

我创建了一个按钮,如果我点击事件,视图必须被解除并显示上一个视图。我使用了以下代码:

     partial void canceldata (NSObject sender)
    {
        Console.WriteLine("canceldata");

        //NavigationController.PopToViewController(settrls,true);
                    this.NavigationController.PopViewControllerAnimated(true);

    }

但是这段代码不起作用。有人建议我通过单击iOS mono touch示例中的按钮来解除当前视图。

1 个答案:

答案 0 :(得分:0)

这取决于您打开该控制器的方式。如果它被推入堆栈,则PopViewControllerAnimated()应该正常工作。如果它被显示为模态对话框,例如

NavigationController.PresentViewController(new UINavigationController(new MyDialog()), true, null);

然后你应该打电话给

NavigationController.DismissViewController(true, null);

代替。