你能帮助我吗,我有一个导航栏,有一个后退按钮,当我按下后退按钮我想回到我的视图,但不确定这是正确的方法,我正在做。
public void Login()
{
cmdLogin.TouchUpInside += delegate {
var rootViewController = new UINavigationController();
LoginViewController LVC = new LoginViewController();
rootViewController.PushViewController(LVC, false);
this._window.RootViewController = rootViewController;
this._window.MakeKeyAndVisible();
_backButton = new UIBarButtonItem("Back", UIBarButtonItemStyle.Bordered, onBackSelected);
LVC.NavigationItem.LeftBarButtonItem = _backButton;
LVC.Title = "Login";
};
}
我的onBackSelected看起来像这样。
private void onBackSelected(object o, EventArgs e)
{
_window = new UIWindow (UIScreen.MainScreen.Bounds);
viewController = new CirkelWithButtonsViewController (_window);
_window.RootViewController = viewController;
_window.MakeKeyAndVisible ();
}
我不知道这是否是正确的回归方式?请提供更好的解决方案:)
答案 0 :(得分:0)
navigationController.PopToViewController(yourViewController);
试试这个..
答案 1 :(得分:0)
NavigationController.PopToViewController (yourViewController, true);
是@ jitendra-deore对xamarin.iOS的翻译C#
答案 2 :(得分:0)
这对我有用
NavigationController.PopToRootViewController(true);