【发布时间】:2012-11-13 20:54:16
【问题描述】:
我在UINavigationController 上推送了一个根控制器。
在该根控制器类中,我可以使用this.NavigationController 访问UINavigationController
但是,这个根控制器有一个 ScrollView,我正在向这个 ScrollView 添加子控制器(或更准确地说,这个子控制器的视图)。
我现在想从此类子控制器内部访问 UINavigationController。 以下属性均为空
this.NavigationController
this.ParentViewController
this.PresentedViewController
this.PresentingViewController
在 ObjectiveC 中你似乎可以使用以下代码
YourAppDelegate *del = (YourAppDelegate *)[UIApplication sharedApplication].delegate;
[del.navigationController pushViewController:nextViewController animated:YES];
不幸的是,我不知道如何在 MonoTouch 中将此映射到 C#。 我尝试了以下方法,但它不起作用:
UIApplication.SharedApplication.KeyWindow.RootViewController.NavigationController
我知道我可以将 UINavigationController 对象传递给我的所有类(构造函数中的参数),但这可能不是最干净的方法。
【问题讨论】:
-
我对monotouch不熟悉,但是你必须先设置rootViewController,而不是push它。
标签: c# objective-c ios xamarin.ios uiapplicationdelegate