我正在使用MonoTouch。当我将新的控制器推入UINavigationController的堆栈时,它可以正常工作。当我按下“后退”按钮时,即使在视觉上,也不会触发任何事件,该视图从堆栈中弹出。具体来说,我想使用ViewDidDisappear和ViewDidAppear做一些事情:
SurveyEditor editor = new SurveyEditor(surveyInstance);
NavigationController.PushViewController(editor, true);
然后在SurveyEditor中:
public override void ViewWillDisappear (bool animated)
{
Console.WriteLine("SurveyEditor ViewWillDisappear");
base.ViewWillDisappear (animated);
}
public override void ViewDidDisappear (bool animated)
{
Console.WriteLine("SurveyEditor ViewDidDisappear");
base.ViewDidDisappear (animated);
}
这些都没有被调用,在我的根视图中,ViewDidAppear也没有被调用!开始对此失去理智。
最佳答案
如果使用以下命令从视图控制器启动导航控制器,则会被调用:
[self presentModalViewController:navigationController animated:YES];
(很抱歉,这不是MonoTouch-我在常规的Objective-C中遇到了问题。这是我的解决方案。)
Look at Dustin Clark's comment here.