我是Xamarin的新手。我进行了很多搜索,以了解我的ViewController是推送还是显示。因此,我将弹出它或相应地将其关闭,但失败了。
2 回答

慕无忌1623718
TA贡献1744条经验 获得超4个赞
您只需要检查Navigation Stack中是否存在当前的viewcontroller 。
解决方案
if(this.NavigationController == null)
{
this.DismissViewController(true, null);
}
else
{
this.NavigationController.PopViewController(true);
}

qq_花开花谢_0
TA贡献1835条经验 获得超7个赞
您可以使用以下方法
private static UIViewController GetController()
{
var vc = UIApplication.SharedApplication.KeyWindow.RootViewController;
while (vc.PresentedViewController != null && vc.PresentedViewController.ToString().Contains("Xamarin_Forms_Platform_iOS_ModalWrapper"))
vc = vc.PresentedViewController;
return vc;
}
如果返回的结果不为null,则表示您的堆栈中存在Present控制器
- 2 回答
- 0 关注
- 158 浏览
添加回答
举报
0/150
提交
取消