gpt4 book ai didi

ios - 从堆栈中弹出当前 View 并推送新 View Xamarin

转载 作者:塔克拉玛干 更新时间:2023-11-02 09:56:46 25 4
gpt4 key购买 nike

我有一个应用程序,我在注册表中,当用户点击提交时,它会将他们带到上一页。在上一页上时,如果用户单击后退,则会将他们带回我不想要的注册页面。如何从堆栈中删除该注册 View ?

这是我目前的做法:

//inside MyRegistrationController button press
MyPreviousController SVC = this.Storyboard.InstantiateViewController("MyPreviousController") as MyPreviousController;
if(SVC != null){
SVC.offender = offender;


//var viewControllers = this.NavigationController.ViewControllers;
//viewControllers[viewControllers.Length - 1].View.RemoveFromSuperview();
//this.NavigationController.ViewControllers = viewControllers;

this.NavigationController.PopViewController(true);
this.NavigationController.PushViewController(SVC, true);
}

当前的方法对堆栈做了一些奇怪的事情,我点击 MyRegistrationController 上的按钮 我转到 MyPreviousController(未更新)然后快速转到更新版本MyPreviousController 回到 MyPreviousController 的更新版本,然后如果我点击后退按钮,我会回到 MyPreviousController

最佳答案

好吧,我终于让它开始工作了。我的问题最终是双重的。一个是我需要弹出 View ,两个是我需要重新加载 MyPreviousController 中的表数据(我没有提出这个问题)。所以我需要执行以下操作:

要简单地弹出当前 Controller ,我只需要说:

//inside MyRegistrationController button press
MyPreviousController SVC = this.Storyboard.InstantiateViewController("MyPreviousController") as MyPreviousController;
if(SVC != null){
SVC.offender = offender;

this.NavigationController.PopViewController(true);
}

但是这样做会导致我在 MyPrevious 中的表无法更新。所以我需要把它放在 MyPreviousController.cs 中:

public override void ViewWillAppear (bool animated)
{
base.ViewWillAppear (animated);
InvokeOnMainThread (delegate {
TableView.Source = source;
TableView.ReloadData();
});
}

并且成功更新了表并删除了注册 View

关于ios - 从堆栈中弹出当前 View 并推送新 View Xamarin,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37550852/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com