我正在使用各种命令来浏览我的应用:
NavigationController.PushViewController( ... );
NavigationController.PopViewControllerAnimated( ... );
在我的应用程序中,它可能会四处游荡并在推动的视图控制器中获得一些深度。我想在超过15-20级深度时弹出一条消息。我可以添加自己的计数器,但有没有办法确定导航控制器堆栈的深度?
答案 0 :(得分:0)
找到我的答案
public override void ViewWillAppear(bool animated) {
base.ViewWillAppear( animated );
int DEPTH = NavigationController.ViewControllers.Count();
if ( DEPTH > 15 ) {
MessageManager.MessageBox("Warning: You have navigated "
+ DEPTH
+ " levels forward into the model. Navigating too many levels can be confusing for many users.");
}
}